git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH/v3] bundle.c: added --stdin option to git-bundle
@ 2008-07-05 16:30 Adam Brewster
  2008-07-05 16:54 ` Jakub Narebski
  2008-07-05 18:15 ` Junio C Hamano
  0 siblings, 2 replies; 20+ messages in thread
From: Adam Brewster @ 2008-07-05 16:30 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Mark Levedahl, Junio C Hamano,
	Jakub Narebski

Signed-off-by: Adam Brewster <asb@bu.edu>
---
It seems that the consensus is that the other half of my original
patch is no good.  You have some pretty good ideas about how to
correctly address the problem I was trying to solve, and I look
forward to seeing them actually implemented.

For now, I offer separately the modification I made to bundle.c to
allow git-bundle to handle the --stdin option.  There is no
accompanying change to the documentation because it already implies
that this option is available.

 bundle.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/bundle.c b/bundle.c
index 0ba5df1..b44a4af 100644
--- a/bundle.c
+++ b/bundle.c
@@ -227,8 +227,26 @@ int create_bundle(struct bundle_header *header,
const char *path,

        /* write references */
        argc = setup_revisions(argc, argv, &revs, NULL);
-       if (argc > 1)
-               return error("unrecognized argument: %s'", argv[1]);
+
+       for (i = 1; i < argc; i++) {
+               if ( !strcmp(argv[i], "--stdin") ) {
+                       char line[1000];
+                               while (fgets(line, sizeof(line),
stdin) != NULL) {
+                               int len = strlen(line);
+                               if (len && line[len - 1] == '\n')
+                                       line[--len] = '\0';
+                               if (!len)
+                                       break;
+                               if (line[0] == '-')
+                                       die("options not supported in
--stdin mode");
+                               if (handle_revision_arg(line, &revs, 0, 1))
+                                       die("bad revision '%s'", line);
+                       }
+                       continue;
+               }
+
+               return error("unrecognized argument: %s'", argv[i]);
+       }

        for (i = 0; i < revs.pending.nr; i++) {
                struct object_array_entry *e = revs.pending.objects + i;
--
1.5.5.1.211.g65ea3.dirty

^ permalink raw reply related	[flat|nested] 20+ messages in thread
* Re: [PATCH v3 1/3] ref-filter: add worktreepath atom
@ 2018-12-20 14:59 Jeff King
  2018-12-24  8:47 ` [PATCH v4 0/3] nbelakovski
  0 siblings, 1 reply; 20+ messages in thread
From: Jeff King @ 2018-12-20 14:59 UTC (permalink / raw)
  To: Nickolai Belakovski
  Cc: git, Rafael Ascensão, Junio C Hamano,
	Ævar Arnfjörð Bjarmason

On Wed, Dec 19, 2018 at 11:09:59PM -0800, Nickolai Belakovski wrote:

> > Also, why are we replacing it with a single space? Wouldn't the empty
> > string be more customary (and work with the other "if empty, then do
> > this" formatting options)?
> 
> I was just following what was done for HEAD, but overall I agree that
> empty is preferable to single space, will change.

Ah, right, that makes more sense. I do still think for %(HEAD) it's a
little different because it is "+" or a single space, so always one
character.  Here we have some value or not, and in the "not" case for
such things we usually give an empty string (e.g., for %(push),
%(upstream), etc).

> To sum up the hashmap comments:
> -I hadn't thought to re-use the head_ref of worktree as the key.
> That's clever. I like the readability of having separate entries for
> key and value, but I can see the benefit of not having to do an extra
> allocation. I can make up for the readability hit with a comment.

Thanks, that makes sense.

> -Actually, for any valid use case there will only be one instance of
> the map since the entries of used_atom are cached, but regardless it
> makes sense to keep per-atom info in used_atom and global context
> somewhere else, so I'll make that change to make it a static variable
> outside of used_atom.

Ah, right, I forgot there was some magic around used_atom. I do still
agree that the separate static global makes things a little simpler.

> -Will change the lookup logic to remove the extra allocation. Since
> I'm letting the hashmap use its internal comparison function on the
> hash, I don't need to provide a comparison function.

I don't think that works. The default function is always_equal(), which
will treat two entries equal if they have the same hash value. I.e., any
collisions would be considered a match.

> Thanks for all the feedback, will try to turn these around quickly.

Great, thanks! I'll be on vacation for the next two weeks, so I may be
very slow to look at the next iteration. :)

-Peff

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-01-03  5:23 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-05 16:30 [PATCH/v3] bundle.c: added --stdin option to git-bundle Adam Brewster
2008-07-05 16:54 ` Jakub Narebski
2008-07-05 18:15 ` Junio C Hamano
2008-07-05 20:40   ` [PATCH v4 0/3] Adam Brewster
2008-07-05 20:40     ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 20:40       ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-05 20:40         ` [PATCH] Add git-basis.perl to contrib directory Adam Brewster
2008-07-05 20:48       ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Miklos Vajna
2008-07-05 21:26         ` [PATCH v5] Adam Brewster
2008-07-05 21:26           ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Adam Brewster
2008-07-05 21:26             ` [PATCH] git-bundle: add --stdin Adam Brewster
2008-07-06  0:57               ` Teach git-bundle to read revision arguments from stdin like git-rev-list Junio C Hamano
2008-07-06 14:28                 ` Adam Brewster
2008-07-06 14:28                   ` [PATCH] git-rev-list: tolerate multiple --stdin options Adam Brewster
2008-07-06 14:28                     ` [PATCH] Teach git-bundle to read revision arguments from stdin like Adam Brewster
2008-07-06  1:50           ` [PATCH v5] Junio C Hamano
2008-07-06  2:49             ` Adam Brewster
2008-07-06  0:57         ` [PATCH] Move read_revisions_from_stdin from builtin-rev-list.c to revision.c Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2018-12-20 14:59 [PATCH v3 1/3] ref-filter: add worktreepath atom Jeff King
2018-12-24  8:47 ` [PATCH v4 0/3] nbelakovski
2019-01-03  5:22   ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).