Re: Pushing and pulling the result of `git replace` and objects/info/alternates
On 05/24/2015 07:28 AM, Christian Couder wrote: Hi, On Fri, May 22, 2015 at 4:38 PM, Stephen Kelly steve...@gmail.com wrote: I have tried out using `git replace --graft` and .git/objects/info/alternates to 'refer to' the history in the origin repo instead of 'duplicating' it. This is similar to how Qt5 repos refer to Qt 4 history in a different repo. Question 1) Is this a reasonable thing to do for this scenario? I think it should work without too much work, but see the answer to the next question. Ok, thanks. The concern is that there is plenty of documentation for git-filter-branch, but no documentation or porcelain for info/alternates and little out on the internet about it or git replace and using them together. However, it seems to be a reasonable thing to do. echo ../../calculator/objects ../.git/modules/compute/objects/info/alternates git replace --graft HEAD $extraction_sha Maybe use the following instead of the above line: git fetch 'refs/replace/*:refs/replace/*' Thanks. # And now we see the history from the calculator repo. Great. But, it required user action after the clone. Yeah, but if the 2 above commands are in a script maybe it's reasonable to ask the user to launch the script once after cloning. Would it be possible to do this in a hook in the 'integration repo' which contains both submodules in the example I posted? Like a fetch hook or something? Thanks, Steve. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] completion: suggest sequencer commands for revert
Signed-off-by: Thomas Braun thomas.br...@virtuell-zuhause.de --- Hi, I added the sequencer commands for git revert. These are handy in case a git revert needs manual intervention. Thanks, Thomas contrib/completion/git-completion.bash | 5 + 1 file changed, 5 insertions(+) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index bfc74e9..3c00acd 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2282,6 +2282,11 @@ _git_reset () _git_revert () { + local dir=$(__gitdir) + if [ -f $dir/REVERT_HEAD ]; then + __gitcomp --continue --quit --abort + return + fi case $cur in --*) __gitcomp --edit --mainline --no-edit --no-commit --signoff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Pushing and pulling the result of `git replace` and objects/info/alternates
On Mon, May 25, 2015 at 11:49 AM, Stephen Kelly steve...@gmail.com wrote: On 05/24/2015 07:28 AM, Christian Couder wrote: Hi, On Fri, May 22, 2015 at 4:38 PM, Stephen Kelly steve...@gmail.com wrote: I have tried out using `git replace --graft` and .git/objects/info/alternates to 'refer to' the history in the origin repo instead of 'duplicating' it. This is similar to how Qt5 repos refer to Qt 4 history in a different repo. Question 1) Is this a reasonable thing to do for this scenario? I think it should work without too much work, but see the answer to the next question. Ok, thanks. The concern is that there is plenty of documentation for git-filter-branch, but no documentation or porcelain for info/alternates and little out on the internet about it or git replace and using them together. However, it seems to be a reasonable thing to do. Yeah. By the way it looks like I was wrong in my answer to your second question. You might want to clone using the --reference option to automatically set up .git/objects/info/alternates properly. (There is an ongoing related thread on the list: http://thread.gmane.org/gmane.comp.version-control.git/269537) You might also be able to clone using an option like --config remote.origin.fetch = 'refs/replace/*:refs/replace/*' to fetch the replace ref when cloning. So it looks like you might just need to clone with a few more options than usual. I haven't tested it so please tell me if it works :-) echo ../../calculator/objects ../.git/modules/compute/objects/info/alternates git replace --graft HEAD $extraction_sha Maybe use the following instead of the above line: git fetch 'refs/replace/*:refs/replace/*' Thanks. # And now we see the history from the calculator repo. Great. But, it required user action after the clone. Yeah, but if the 2 above commands are in a script maybe it's reasonable to ask the user to launch the script once after cloning. Would it be possible to do this in a hook in the 'integration repo' which contains both submodules in the example I posted? Like a fetch hook or something? It is possible to do whatever you want in a hook, but the question is why would you do it in a hook as it looks like it needs to be done only once? Or maybe I am missing something? Best, Christian. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/2] ref-filter: move code from 'for-each-ref'
Move most of the code from 'for-each-ref' to 'ref-filter' to make it publically available to other commands, this is to unify the code of 'tag -l', 'branch -l' and 'for-each-ref' so that they can share their implementations with each other. Mentored-by: Christian Couder christian.cou...@gmail.com Mentored-by: Matthieu Moy matthieu@grenoble-inp.fr Signed-off-by: Karthik Nayak karthik@gmail.com --- Makefile |1 + builtin/for-each-ref.c | 1089 +--- ref-filter.c | 1051 ++ ref-filter.h | 65 +++ 4 files changed, 1118 insertions(+), 1088 deletions(-) create mode 100644 ref-filter.c create mode 100644 ref-filter.h diff --git a/Makefile b/Makefile index 36655d5..068d313 100644 --- a/Makefile +++ b/Makefile @@ -761,6 +761,7 @@ LIB_OBJS += reachable.o LIB_OBJS += read-cache.o LIB_OBJS += reflog-walk.o LIB_OBJS += refs.o +LIB_OBJS += ref-filter.o LIB_OBJS += remote.o LIB_OBJS += replace_object.o LIB_OBJS += rerere.o diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index eb502a1..dc95f8d 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -1,1095 +1,8 @@ #include builtin.h #include cache.h #include refs.h -#include object.h -#include tag.h -#include commit.h -#include tree.h -#include blob.h -#include quote.h +#include ref-filter.h #include parse-options.h -#include remote.h -#include color.h - -/* Quoting styles */ -#define QUOTE_NONE 0 -#define QUOTE_SHELL 1 -#define QUOTE_PERL 2 -#define QUOTE_PYTHON 4 -#define QUOTE_TCL 8 - -typedef enum { FIELD_STR, FIELD_ULONG, FIELD_TIME } cmp_type; - -struct atom_value { - const char *s; - unsigned long ul; /* used for sorting when not FIELD_STR */ -}; - -struct ref_sort { - struct ref_sort *next; - int atom; /* index into used_atom array */ - unsigned reverse : 1; -}; - -struct ref_filter_item { - unsigned char sha1[20]; - int flags; - const char *symref; - struct atom_value *value; - char *name; -}; - -struct ref_list { - int nr, alloc; - struct ref_filter_item **items; -}; - -struct ref_filter { - const char **name_patterns; -}; - -struct ref_filter_data { - struct ref_list list; - struct ref_filter filter; -}; - -static struct { - const char *name; - cmp_type cmp_type; -} valid_atom[] = { - { refname }, - { objecttype }, - { objectsize, FIELD_ULONG }, - { objectname }, - { tree }, - { parent }, - { numparent, FIELD_ULONG }, - { object }, - { type }, - { tag }, - { author }, - { authorname }, - { authoremail }, - { authordate, FIELD_TIME }, - { committer }, - { committername }, - { committeremail }, - { committerdate, FIELD_TIME }, - { tagger }, - { taggername }, - { taggeremail }, - { taggerdate, FIELD_TIME }, - { creator }, - { creatordate, FIELD_TIME }, - { subject }, - { body }, - { contents }, - { contents:subject }, - { contents:body }, - { contents:signature }, - { upstream }, - { symref }, - { flag }, - { HEAD }, - { color }, -}; - -/* - * An atom is a valid field atom listed above, possibly prefixed with - * a * to denote deref_tag(). - * - * We parse given format string and sort specifiers, and make a list - * of properties that we need to extract out of objects. ref_filter_item - * structure will hold an array of values extracted that can be - * indexed with the atom number, which is an index into this - * array. - */ -static const char **used_atom; -static cmp_type *used_atom_type; -static int used_atom_cnt, need_tagged, need_symref; -static int need_color_reset_at_eol; - -/* - * Used to parse format string and sort specifiers - */ -int parse_atom(const char *atom, const char *ep) -{ - const char *sp; - int i, at; - - sp = atom; - if (*sp == '*' sp ep) - sp++; /* deref */ - if (ep = sp) - die(malformed field name: %.*s, (int)(ep-atom), atom); - - /* Do we have the atom already used elsewhere? */ - for (i = 0; i used_atom_cnt; i++) { - int len = strlen(used_atom[i]); - if (len == ep - atom !memcmp(used_atom[i], atom, len)) - return i; - } - - /* Is the atom a valid one? */ - for (i = 0; i ARRAY_SIZE(valid_atom); i++) { - int len = strlen(valid_atom[i].name); - /* -* If the atom name has a colon, strip it and everything after -* it off - it specifies the format for this entry, and -* shouldn't be used for checking against the valid_atom -* table. -*/ - const char *formatp = strchr(sp, ':'); - if (!formatp
[WIP][Patch v2 0/2] Ref-filter: unification of 'tag -l', 'branch -l' and 'for-each-ref'
Hello, After the 1st version of the WIP patch ($gmane/269461) this is a follow up. Changes since 1st version : * restructure to have 'struct ref_filter_data' which has a list of refs 'struct ref_list list', and the filters to apply 'struct ref_filter filter' * reformat the commit to be better structured and easier to track and more 'git blame' friendly. * other small changes. Also I'll be maintaining a repo on Github where I'll be pushing code more often. https://github.com/KarthikNayak/git -- Regards, Karthik -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/2] for-each-ref: re-structure code for moving to 'ref-filter'
Re-factoring and renaming of code to make meaningful, targeted services available to other commands in efforts to change private scope of the code to public API by moving it to 'ref-filter'. Restructuring of code done to further modularize it to make API provisions simple and effective. Rename 'refinfo' to 'ref_filter_item' and intoduce 'ref_filter_data' which will hold 'ref_filter' (Conditions to filter the refs on) and 'ref_list' (The list of ref_filter_items). Modify the code to use 'ref_filter_data' and make some of the functions publically available by removind the static file scope. Based-on-patch-by: Jeff King p...@peff.net Mentored-by: Christian Couder christian.cou...@gmail.com Mentored-by: Matthieu Moy matthieu@grenoble-inp.fr Signed-off-by: Karthik Nayak karthik@gmail.com --- builtin/for-each-ref.c | 212 - 1 file changed, 121 insertions(+), 91 deletions(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 83f9cf9..eb502a1 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -31,12 +31,26 @@ struct ref_sort { unsigned reverse : 1; }; -struct refinfo { - char *refname; - unsigned char objectname[20]; - int flag; +struct ref_filter_item { + unsigned char sha1[20]; + int flags; const char *symref; struct atom_value *value; + char *name; +}; + +struct ref_list { + int nr, alloc; + struct ref_filter_item **items; +}; + +struct ref_filter { + const char **name_patterns; +}; + +struct ref_filter_data { + struct ref_list list; + struct ref_filter filter; }; static struct { @@ -85,7 +99,7 @@ static struct { * a * to denote deref_tag(). * * We parse given format string and sort specifiers, and make a list - * of properties that we need to extract out of objects. refinfo + * of properties that we need to extract out of objects. ref_filter_item * structure will hold an array of values extracted that can be * indexed with the atom number, which is an index into this * array. @@ -98,7 +112,7 @@ static int need_color_reset_at_eol; /* * Used to parse format string and sort specifiers */ -static int parse_atom(const char *atom, const char *ep) +int parse_atom(const char *atom, const char *ep) { const char *sp; int i, at; @@ -175,7 +189,7 @@ static const char *find_next(const char *cp) * Make sure the format string is well formed, and parse out * the used atoms. */ -static int verify_format(const char *format) +int verify_format(const char *format) { const char *cp, *sp; @@ -622,7 +636,7 @@ static inline char *copy_advance(char *dst, const char *src) /* * Parse the object referred by ref, and grab needed value. */ -static void populate_value(struct refinfo *ref) +static void populate_value(struct ref_filter_item *ref) { void *buf; struct object *obj; @@ -632,9 +646,9 @@ static void populate_value(struct refinfo *ref) ref-value = xcalloc(used_atom_cnt, sizeof(struct atom_value)); - if (need_symref (ref-flag REF_ISSYMREF) !ref-symref) { + if (need_symref (ref-flags REF_ISSYMREF) !ref-symref) { unsigned char unused1[20]; - ref-symref = resolve_refdup(ref-refname, RESOLVE_REF_READING, + ref-symref = resolve_refdup(ref-name, RESOLVE_REF_READING, unused1, NULL); if (!ref-symref) ref-symref = ; @@ -655,14 +669,14 @@ static void populate_value(struct refinfo *ref) } if (starts_with(name, refname)) - refname = ref-refname; + refname = ref-name; else if (starts_with(name, symref)) refname = ref-symref ? ref-symref : ; else if (starts_with(name, upstream)) { /* only local branches may have an upstream */ - if (!starts_with(ref-refname, refs/heads/)) + if (!starts_with(ref-name, refs/heads/)) continue; - branch = branch_get(ref-refname + 11); + branch = branch_get(ref-name + 11); if (!branch || !branch-merge || !branch-merge[0] || !branch-merge[0]-dst) @@ -677,9 +691,9 @@ static void populate_value(struct refinfo *ref) continue; } else if (!strcmp(name, flag)) { char buf[256], *cp = buf; - if (ref-flag REF_ISSYMREF) + if (ref-flags REF_ISSYMREF) cp = copy_advance(cp, ,symref); - if (ref-flag REF_ISPACKED) + if (ref-flags REF_ISPACKED) cp = copy_advance(cp, ,packed);
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
On Sat, May 23, 2015 at 6:24 PM, Allen Hubbe alle...@gmail.com wrote: On Sat, May 23, 2015 at 2:07 PM, Junio C Hamano gits...@pobox.com wrote: Junio C Hamano gits...@pobox.com writes: A small thing I noticed in the test (and this patch is not adding a new breakage---there are a few existing instances) is the use of ~/; it should be spelled $HOME/ instead for portability (not in POSIX, even though bash, dash and ksh all seem to understand it). Well, I was wrong. Tilde expansion is in POSIX. Nevertheless, I'd prefer if we avoided it. Alright, $HOME it will be. Looking closer at this and the other test cases, they are inconsistent about using .mailrc, ~/.mailrc, and $(pwd)/.mailrc. This would add another one, $HOME/.mailrc. How do you feel about using just .mailrc, and $(pwd)/.mailrc when an absolute path is needed in gitconfig? -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] for-each-ref: re-structure code for moving to 'ref-filter'
Karthik Nayak karthik@gmail.com writes: -struct refinfo { - char *refname; - unsigned char objectname[20]; - int flag; +struct ref_filter_item { + unsigned char sha1[20]; + int flags; const char *symref; struct atom_value *value; + char *name; +}; I do not see much point in renaming between these two. The latter makes it sound as if this is only for filtering and from that angle of view is probably a worse name. If you do not think of a better one, and if you are going to name the array that contains this thing ref_list, calling ref_list_item would be following suit to what string-list did. I somehow had an impression that we are trying to move away from calling the name of objects as sha1[] as a longer term goal? I do not think it is particularly a good idea to start using struct object_id in this series (it can be done after everything is done and you still have time left in GSoC), but I do not see how much value this interim renaming (because eventually we would change not just name but type, and the final name will _not_ be sha1[] but more closer to object name) adds value. You didn't explain why you reordered the fields, either. Were you planning to make the name[] field to flex-array to reduce need for one level of redirection or something? + +struct ref_list { + int nr, alloc; + struct ref_filter_item **items; +}; + +struct ref_filter { + const char **name_patterns; +}; + +struct ref_filter_data { + struct ref_list list; + struct ref_filter filter; }; I agree that grab part of grab_ref_cbdata sounds unprofessional, and using ref_filter_ to signal that this callback data is about ref-filter API might be a good idea (I do not think the original is too bad, either, though). I do not think you would use this struct anywhere other than as the callback data; you would want to end its name with _cbdata, not just _data, to make it clear why these two unrelated things are in a single struct (the only time these two concepts, operation and operatee, meet is when they need to be passed to an apply operation to operatee function; there is no such this set of operatee always are for this operation association between them---which is what I mean by 'two unrelated things'). @@ -98,7 +112,7 @@ static int need_color_reset_at_eol; /* * Used to parse format string and sort specifiers */ -static int parse_atom(const char *atom, const char *ep) +int parse_atom(const char *atom, const char *ep) It was perfectly good name as a file-scope static; within the context of 'for-each-ref' implementation, when every somebody says atom, you would know it is those %(atomic-data-item) things, and parse_atom() would be a helper function to do so. But it is *WAY* too generic a name to make public, where you are naming things in the whole context of Git implementation. If you used the word atom while discussing formatting done with git for-each-ref with somebody else, it would be unambiguously clear what you mean; you wouldn't say I am writing a function to parse 'atoms' in Git---that's too broad and you will get 'atom', in what sense? in response. @@ -175,7 +189,7 @@ static const char *find_next(const char *cp) * Make sure the format string is well formed, and parse out * the used atoms. */ -static int verify_format(const char *format) +int verify_format(const char *format) Ditto. @@ -622,7 +636,7 @@ static inline char *copy_advance(char *dst, const char *src) /* * Parse the object referred by ref, and grab needed value. */ -static void populate_value(struct refinfo *ref) +static void populate_value(struct ref_filter_item *ref) { As long as this will stay private within the new ref-filter.c after the move, this name is OK. @@ -655,14 +669,14 @@ static void populate_value(struct refinfo *ref) } if (starts_with(name, refname)) - refname = ref-refname; + refname = ref-name; else if (starts_with(name, symref)) refname = ref-symref ? ref-symref : ; else if (starts_with(name, upstream)) { /* only local branches may have an upstream */ - if (!starts_with(ref-refname, refs/heads/)) + if (!starts_with(ref-name, refs/heads/)) continue; - branch = branch_get(ref-refname + 11); + branch = branch_get(ref-name + 11); if (!branch || !branch-merge || !branch-merge[0] || !branch-merge[0]-dst) @@ -677,9 +691,9 @@ static void populate_value(struct refinfo *ref) continue; } else if (!strcmp(name, flag)) { char buf[256], *cp = buf; - if (ref-flag REF_ISSYMREF) + if (ref-flags REF_ISSYMREF)
Re: Suggestion to add a new command(git print-tree)
With discussions i have on the irc channel(#git) i just noticed there is the git ls-tree command but it doesn't format the tree so it will be a good thing for the tree to be formatted. I will like to embark on the project. Regards Alangi Derick Ndimnain On Mon, May 25, 2015 at 5:17 PM, Alangi Derick alangider...@gmail.com wrote: Hello everyone, I will like us to discuss on this topic to add a new command into git that will enable us to print the entire working tree in a git repository. Something similar to work happens when you run the linux command: pstree. This is important in searching and also more that i will be discussing while talking about the idea. Thanks and if there is anything to say about this, feel free to comment. Regards Alangi Derick Ndimnain -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] Fixed a typographical error
From e8c2ea38865cf5dcc135e34ec2e80def8736b582 Mon Sep 17 00:00:00 2001 From: Alangi Derick alangider...@gmail.com Date: Sun, 24 May 2015 14:58:30 +0100 Subject: [PATCH] Fixed a typographical error This is a patch to fix a typographical error in the 2.5.0.txt file in the Documentation/RelNotes directory. The error was in the word thoughout which was to be spelled throughout based on the context of the sentence. Signed-off-by: Alangi Derick alangider...@gmail.com --- Documentation/RelNotes/2.5.0.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/RelNotes/2.5.0.txt b/Documentation/RelNotes/2.5.0.txt index a11e53c..02fdc66 100644 --- a/Documentation/RelNotes/2.5.0.txt +++ b/Documentation/RelNotes/2.5.0.txt @@ -32,7 +32,7 @@ UI, Workflows Features Performance, Internal Implementation, Development Support etc. - * unsigned char [20] used thoughout the code to represent object + * unsigned char [20] used throughout the code to represent object names are being converted into a semi-opaque struct object_id. This effort is expected to interfere with other topics in flight, but hopefully will give us one extra level of abstraction in the -- 2.4.0.53.g8440f74.dirty -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Suggestion to add a new command(git print-tree)
Regards Alangi Derick Ndimnain On Mon, May 25, 2015 at 5:21 PM, Alangi Derick alangider...@gmail.com wrote: With discussions i have on the irc channel(#git) i just noticed there is the git ls-tree command but it doesn't format the tree so it will be a good thing for the tree to be formatted. I will like to embark on the project. Regards Alangi Derick Ndimnain On Mon, May 25, 2015 at 5:17 PM, Alangi Derick alangider...@gmail.com wrote: Hello everyone, I will like us to discuss on this topic to add a new command into git that will enable us to print the entire working tree in a git repository. Something similar to work happens when you run the linux command: pstree. This is important in searching and also more that i will be discussing while talking about the idea. Thanks and if there is anything to say about this, feel free to comment. Regards Alangi Derick Ndimnain Sorry for topping post, i forgot. Just like i said above, it will be good that commands like; git ls-tree, git ls-files and more commands of git that list directories to do them in a tree-like manner. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Allen Hubbe alle...@gmail.com writes: Looking closer at this and the other test cases, they are inconsistent about using .mailrc, ~/.mailrc, and $(pwd)/.mailrc. This would add another one, $HOME/.mailrc. In t9001, I see two tests on mailrc: * Create .mailrc in the current directory and point at it from the configuration file sendemail.aliasfile with $(pwd)/.mailrc This one is correct in that test wants to make sure an absolute path is usable as the value; the creation in the current directory (hence .mailrc) is a mere implementation detail that the file it wants to use can be created by pathname relative to the current directory when echo is run. * Create ~/.mailrc, relying on tilde expansion of the shell when echo is run, and then point at it from the configuration file as ~/.mailrc. The former, i.e. echo ... ~/.mailrc should instead redirect into $HOME/.mailrc in order to support shells that do not understand tilde expansion. However, the latter is correct, as this test wants to make sure that whoever reads the configuration interprets ~/.mailrc as file .mailrc in the home directory, without help from the shell. Specifically, the difference between these two tests is not inconcistency; they are covering two different use patterns. So I do not see any reason to change most of these; except that the target of 'echo' should be changed from ~/.mailrc to $HOME/.mailrc. Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v11 5/5] help: respect new common command grouping
On 05/21/2015 08:04 PM, Eric Sunshine wrote: On Thu, May 21, 2015 at 1:39 PM, Sébastien Guimmara sebastien.guimm...@gmail.com wrote: 'git help' shows common commands in alphabetical order: The most commonly used git commands are: addAdd file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a repository into a new directory commit Record changes to the repository [...] without any indication of how commands relate to high-level concepts or each other. Revise the output to explain their relationship with the typical Git workflow: The most commonly used git commands are: The above line in the commit message does not match the actual output: These are common Git commands used in various situations: Thanks. Will correct this. start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize [...] work on the current change (see also: git help everyday) addAdd file contents to the index reset Reset current HEAD to the specified state examine the history and state (see also: git help revisions) logShow commit logs status Show the working tree status [...] Helped-by: Eric Sunshine sunsh...@sunshineco.com Signed-off-by: Ramsay Jones ram...@ramsay1.demon.co.uk Signed-off-by: Sébastien Guimmara sebastien.guimm...@gmail.com --- diff --git a/help.c b/help.c index 2072a87..8f72051 100644 --- a/help.c +++ b/help.c @@ -218,17 +218,39 @@ void list_commands(unsigned int colopts, } } +static int cmd_group_cmp(const void *elem1, const void *elem2) +{ + const struct cmdname_help *e1 = elem1; + const struct cmdname_help *e2 = elem2; + + if (e1-group e2-group) + return -1; + if (e1-group e2-group) + return 1; + return strcmp(e1-name, e2-name); +} + void list_common_cmds_help(void) { int i, longest = 0; + int current_grp = -1; for (i = 0; i ARRAY_SIZE(common_cmds); i++) { if (longest strlen(common_cmds[i].name)) longest = strlen(common_cmds[i].name); } - puts(_(The most commonly used git commands are:)); + qsort(common_cmds, ARRAY_SIZE(common_cmds), + sizeof(common_cmds[0]), cmd_group_cmp); + + puts(_(These are common Git commands used in various situations:)); + for (i = 0; i ARRAY_SIZE(common_cmds); i++) { + if (common_cmds[i].group != current_grp) { + printf(\n%s\n, _(common_cmd_groups[common_cmds[i].group])); + current_grp = common_cmds[i].group; + } + printf( %s , common_cmds[i].name); mput_char(' ', longest - strlen(common_cmds[i].name)); puts(_(common_cmds[i].help)); -- 2.4.0.GIT -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Suggestion to add a new command(git print-tree)
Hello everyone, I will like us to discuss on this topic to add a new command into git that will enable us to print the entire working tree in a git repository. Something similar to work happens when you run the linux command: pstree. This is important in searching and also more that i will be discussing while talking about the idea. Thanks and if there is anything to say about this, feel free to comment. Regards Alangi Derick Ndimnain -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 35/56] remote: rewrite functions to take object_id arguments
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- remote.c | 19 --- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/remote.c b/remote.c index 6d66ec1..1623eae 100644 --- a/remote.c +++ b/remote.c @@ -2024,7 +2024,8 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb) return 1; } -static int one_local_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int one_local_ref(const char *refname, const struct object_id *oid, +int flag, void *cb_data) { struct ref ***local_tail = cb_data; struct ref *ref; @@ -2036,7 +2037,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla len = strlen(refname) + 1; ref = xcalloc(1, sizeof(*ref) + len); - hashcpy(ref-new_sha1, sha1); + hashcpy(ref-new_sha1, oid-hash); memcpy(ref-name, refname, len); **local_tail = ref; *local_tail = ref-next; @@ -2046,10 +2047,8 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla struct ref *get_local_heads(void) { struct ref *local_refs = NULL, **local_tail = local_refs; - struct each_ref_fn_sha1_adapter wrapped_one_local_ref = - {one_local_ref, local_tail}; - for_each_ref(each_ref_fn_adapter, wrapped_one_local_ref); + for_each_ref(one_local_ref, local_tail); return local_refs; } @@ -2101,8 +2100,8 @@ struct stale_heads_info { int ref_count; }; -static int get_stale_heads_cb(const char *refname, - const unsigned char *sha1, int flags, void *cb_data) +static int get_stale_heads_cb(const char *refname, const struct object_id *oid, + int flags, void *cb_data) { struct stale_heads_info *info = cb_data; struct string_list matches = STRING_LIST_INIT_DUP; @@ -2131,7 +2130,7 @@ static int get_stale_heads_cb(const char *refname, if (stale) { struct ref *ref = make_linked_ref(refname, info-stale_refs_tail); - hashcpy(ref-new_sha1, sha1); + hashcpy(ref-new_sha1, oid-hash); } clean_exit: @@ -2144,8 +2143,6 @@ struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fet struct ref *ref, *stale_refs = NULL; struct string_list ref_names = STRING_LIST_INIT_NODUP; struct stale_heads_info info; - struct each_ref_fn_sha1_adapter wrapped_get_stale_heads_cb = - {get_stale_heads_cb, info}; info.ref_names = ref_names; info.stale_refs_tail = stale_refs; @@ -2154,7 +2151,7 @@ struct ref *get_stale_heads(struct refspec *refs, int ref_count, struct ref *fet for (ref = fetch_map; ref; ref = ref-next) string_list_append(ref_names, ref-name); string_list_sort(ref_names); - for_each_ref(each_ref_fn_adapter, wrapped_get_stale_heads_cb); + for_each_ref(get_stale_heads_cb, info); string_list_clear(ref_names, 0); return stale_refs; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 44/56] find_symref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- upload-pack.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 52fab23..96dbedc 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -741,8 +741,8 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo return 0; } -static int find_symref(const char *refname, const unsigned char *sha1, int flag, - void *cb_data) +static int find_symref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { const char *symref_target; struct string_list_item *item; @@ -761,10 +761,8 @@ static int find_symref(const char *refname, const unsigned char *sha1, int flag, static void upload_pack(void) { struct string_list symref = STRING_LIST_INIT_DUP; - struct each_ref_fn_sha1_adapter wrapped_find_symref = - {find_symref, symref}; - head_ref_namespaced(each_ref_fn_adapter, wrapped_find_symref); + head_ref_namespaced(find_symref, symref); if (advertise_refs || !stateless_rpc) { struct each_ref_fn_sha1_adapter wrapped_send_ref = -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 55/56] warn_if_dangling_symref(): convert local variable junk to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- refs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index 162760c..7515c2e 100644 --- a/refs.c +++ b/refs.c @@ -1757,7 +1757,7 @@ int ref_exists(const char *refname) } static int filter_refs(const char *refname, const struct object_id *oid, - int flags, void *data) + int flags, void *data) { struct ref_filter *filter = (struct ref_filter *)data; @@ -1903,12 +1903,12 @@ static int warn_if_dangling_symref(const char *refname, const struct object_id * { struct warn_if_dangling_data *d = cb_data; const char *resolves_to; - unsigned char junk[20]; + struct object_id junk; if (!(flags REF_ISSYMREF)) return 0; - resolves_to = resolve_ref_unsafe(refname, 0, junk, NULL); + resolves_to = resolve_ref_unsafe(refname, 0, junk.hash, NULL); if (!resolves_to || (d-refname ? strcmp(resolves_to, d-refname) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 37/56] handle_one_reflog(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- revision.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/revision.c b/revision.c index cfe3876..1d903cf 100644 --- a/revision.c +++ b/revision.c @@ -1293,7 +1293,8 @@ static int handle_one_reflog_ent(unsigned char *osha1, unsigned char *nsha1, return 0; } -static int handle_one_reflog(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int handle_one_reflog(const char *path, const struct object_id *oid, +int flag, void *cb_data) { struct all_refs_cb *cb = cb_data; cb-warned_bad_reflog = 0; @@ -1305,12 +1306,10 @@ static int handle_one_reflog(const char *path, const unsigned char *sha1, int fl void add_reflogs_to_pending(struct rev_info *revs, unsigned flags) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_reflog = - {handle_one_reflog, cb}; cb.all_revs = revs; cb.all_flags = flags; - for_each_reflog(each_ref_fn_adapter, wrapped_handle_one_reflog); + for_each_reflog(handle_one_reflog, cb); } static void add_cache_tree(struct cache_tree *it, struct rev_info *revs, -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 50/56] mark_complete_oid(): new function, taking an object_oid
From: Michael Haggerty mhag...@alum.mit.edu This function can be used with for_each_ref() without having to be wrapped. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- fetch-pack.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 1e875cf..d7a4a48 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -490,6 +490,12 @@ static int mark_complete(const char *refname, const unsigned char *sha1, int fla return 0; } +static int mark_complete_oid(const char *refname, const struct object_id *oid, +int flag, void *cb_data) +{ + return mark_complete(refname, oid-hash, flag, cb_data); +} + static void mark_recent_complete_commits(struct fetch_pack_args *args, unsigned long cutoff) { @@ -602,10 +608,7 @@ static int everything_local(struct fetch_pack_args *args, } if (!args-depth) { - struct each_ref_fn_sha1_adapter wrapped_mark_complete = - {mark_complete, NULL}; - - for_each_ref(each_ref_fn_adapter, wrapped_mark_complete); + for_each_ref(mark_complete_oid, NULL); for_each_alternate_ref(mark_alternate_complete, NULL); commit_list_sort_by_date(complete); if (cutoff) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 42/56] write_refs_to_temp_dir(): convert local variable sha1 to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- transport.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/transport.c b/transport.c index 58cb9ed..df87386 100644 --- a/transport.c +++ b/transport.c @@ -299,18 +299,18 @@ static int write_one_ref(const char *name, const unsigned char *sha1, } static int write_refs_to_temp_dir(struct strbuf *temp_dir, - int refspec_nr, const char **refspec) + int refspec_nr, const char **refspec) { int i; for (i = 0; i refspec_nr; i++) { - unsigned char sha1[20]; + struct object_id oid; char *ref; - if (dwim_ref(refspec[i], strlen(refspec[i]), sha1, ref) != 1) + if (dwim_ref(refspec[i], strlen(refspec[i]), oid.hash, ref) != 1) return error(Could not get ref %s, refspec[i]); - if (write_one_ref(ref, sha1, 0, temp_dir)) { + if (write_one_ref(ref, oid.hash, 0, temp_dir)) { free(ref); return -1; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 54/56] each_ref_fn_adapter(): remove adapter
From: Michael Haggerty mhag...@alum.mit.edu All of the callers of the for_each_ref family of functions have now been rewritten to work with object_ids, so this adapter is no longer needed. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- refs.c | 8 refs.h | 11 --- 2 files changed, 19 deletions(-) diff --git a/refs.c b/refs.c index 43dce01..162760c 100644 --- a/refs.c +++ b/refs.c @@ -2176,14 +2176,6 @@ int for_each_rawref(each_ref_fn fn, void *cb_data) DO_FOR_EACH_INCLUDE_BROKEN, cb_data); } -int each_ref_fn_adapter(const char *refname, - const struct object_id *oid, int flags, void *cb_data) -{ - struct each_ref_fn_sha1_adapter *cb = cb_data; - - return cb-original_fn(refname, oid-hash, flags, cb-original_cb_data); -} - const char *prettify_refname(const char *name) { return name + ( diff --git a/refs.h b/refs.h index 4042109..8c3d433 100644 --- a/refs.h +++ b/refs.h @@ -69,17 +69,6 @@ struct ref_transaction; typedef int each_ref_fn(const char *refname, const struct object_id *oid, int flags, void *cb_data); -typedef int each_ref_sha1_fn(const char *refname, -const unsigned char *sha1, int flags, void *cb_data); - -struct each_ref_fn_sha1_adapter { - each_ref_sha1_fn *original_fn; - void *original_cb_data; -}; - -extern int each_ref_fn_adapter(const char *refname, - const struct object_id *oid, int flags, void *cb_data); - /* * The following functions invoke the specified callback function for * each reference indicated. If the function ever returns a nonzero -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 32/56] add_ref_decoration(): convert local variable original_sha1 to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- log-tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/log-tree.c b/log-tree.c index abf5cc3..01beb11 100644 --- a/log-tree.c +++ b/log-tree.c @@ -98,14 +98,14 @@ static int add_ref_decoration(const char *refname, const struct object_id *oid, assert(cb_data == NULL); if (starts_with(refname, refs/replace/)) { - unsigned char original_sha1[20]; + struct object_id original_oid; if (!check_replace_refs) return 0; - if (get_sha1_hex(refname + 13, original_sha1)) { + if (get_oid_hex(refname + 13, original_oid)) { warning(invalid replace ref %s, refname); return 0; } - obj = parse_object(original_sha1); + obj = parse_object(original_oid.hash); if (obj) add_name_decoration(DECORATION_GRAFTED, replaced, obj); return 0; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 48/56] mark_complete(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- walker.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/walker.c b/walker.c index bb2e0b9..44a936c 100644 --- a/walker.c +++ b/walker.c @@ -200,9 +200,11 @@ static int interpret_target(struct walker *walker, char *target, unsigned char * return -1; } -static int mark_complete(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int mark_complete(const char *path, const struct object_id *oid, +int flag, void *cb_data) { - struct commit *commit = lookup_commit_reference_gently(sha1, 1); + struct commit *commit = lookup_commit_reference_gently(oid-hash, 1); + if (commit) { commit-object.flags |= COMPLETE; commit_list_insert(commit, complete); @@ -269,10 +271,7 @@ int walker_fetch(struct walker *walker, int targets, char **target, } if (!walker-get_recover) { - struct each_ref_fn_sha1_adapter wrapped_mark_complete = - {mark_complete, NULL}; - - for_each_ref(each_ref_fn_adapter, wrapped_mark_complete); + for_each_ref(mark_complete, NULL); commit_list_sort_by_date(complete); } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 36/56] register_replace_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- replace_object.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/replace_object.c b/replace_object.c index a8a2da9..f0b39f0 100644 --- a/replace_object.c +++ b/replace_object.c @@ -53,7 +53,7 @@ static int register_replace_object(struct replace_object *replace, } static int register_replace_ref(const char *refname, - const unsigned char *sha1, + const struct object_id *oid, int flag, void *cb_data) { /* Get sha1 from refname */ @@ -68,7 +68,7 @@ static int register_replace_ref(const char *refname, } /* Copy sha1 from the read ref */ - hashcpy(repl_obj-replacement, sha1); + hashcpy(repl_obj-replacement, oid-hash); /* Register new object */ if (register_replace_object(repl_obj, 1)) @@ -80,13 +80,11 @@ static int register_replace_ref(const char *refname, static void prepare_replace_object(void) { static int replace_object_prepared; - struct each_ref_fn_sha1_adapter wrapped_register_replace_ref = - {register_replace_ref, NULL}; if (replace_object_prepared) return; - for_each_replace_ref(each_ref_fn_adapter, wrapped_register_replace_ref); + for_each_replace_ref(register_replace_ref, NULL); replace_object_prepared = 1; if (!replace_object_nr) check_replace_refs = 0; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 51/56] mark_complete(): remove unneeded arguments
From: Michael Haggerty mhag...@alum.mit.edu Now that the function is not being used as an each_ref_sha1_fn, we can delete the unused arguments in its signature. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- fetch-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index d7a4a48..13a5000 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -469,7 +469,7 @@ done: static struct commit_list *complete; -static int mark_complete(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int mark_complete(const unsigned char *sha1) { struct object *o = parse_object(sha1); @@ -493,7 +493,7 @@ static int mark_complete(const char *refname, const unsigned char *sha1, int fla static int mark_complete_oid(const char *refname, const struct object_id *oid, int flag, void *cb_data) { - return mark_complete(refname, oid-hash, flag, cb_data); + return mark_complete(oid-hash); } static void mark_recent_complete_commits(struct fetch_pack_args *args, @@ -573,7 +573,7 @@ static void filter_refs(struct fetch_pack_args *args, static void mark_alternate_complete(const struct ref *ref, void *unused) { - mark_complete(NULL, ref-old_sha1, 0, NULL); + mark_complete(ref-old_sha1); } static int everything_local(struct fetch_pack_args *args, -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 31/56] add_ref_decoration(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- log-tree.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/log-tree.c b/log-tree.c index 1a0e170..abf5cc3 100644 --- a/log-tree.c +++ b/log-tree.c @@ -89,7 +89,8 @@ const struct name_decoration *get_name_decoration(const struct object *obj) return lookup_decoration(name_decoration, obj); } -static int add_ref_decoration(const char *refname, const unsigned char *sha1, int flags, void *cb_data) +static int add_ref_decoration(const char *refname, const struct object_id *oid, + int flags, void *cb_data) { struct object *obj; enum decoration_type type = DECORATION_NONE; @@ -110,7 +111,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in return 0; } - obj = parse_object(sha1); + obj = parse_object(oid-hash); if (!obj) return 0; @@ -149,13 +150,11 @@ static int add_graft_decoration(const struct commit_graft *graft, void *cb_data) void load_ref_decorations(int flags) { if (!decoration_loaded) { - struct each_ref_fn_sha1_adapter wrapped_add_ref_decoration = - {add_ref_decoration, NULL}; decoration_loaded = 1; decoration_flags = flags; - for_each_ref(each_ref_fn_adapter, wrapped_add_ref_decoration); - head_ref(each_ref_fn_adapter, wrapped_add_ref_decoration); + for_each_ref(add_ref_decoration, NULL); + head_ref(add_ref_decoration, NULL); for_each_commit_graft(add_graft_decoration, NULL); } } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 45/56] find_symref(): convert local variable unused to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- upload-pack.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 96dbedc..8268037 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -746,11 +746,11 @@ static int find_symref(const char *refname, const struct object_id *oid, { const char *symref_target; struct string_list_item *item; - unsigned char unused[20]; + struct object_id unused; if ((flag REF_ISSYMREF) == 0) return 0; - symref_target = resolve_ref_unsafe(refname, 0, unused, flag); + symref_target = resolve_ref_unsafe(refname, 0, unused.hash, flag); if (!symref_target || (flag REF_ISSYMREF) == 0) die('%s' is a symref but it is not?, refname); item = string_list_append(cb_data, refname); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 56/56] struct ref_lock: convert old_sha1 member to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- refs.c | 24 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/refs.c b/refs.c index 7515c2e..a742d79 100644 --- a/refs.c +++ b/refs.c @@ -10,7 +10,7 @@ struct ref_lock { char *ref_name; char *orig_ref_name; struct lock_file *lk; - unsigned char old_sha1[20]; + struct object_id old_oid; }; /* @@ -2225,16 +2225,16 @@ static struct ref_lock *verify_lock(struct ref_lock *lock, { if (read_ref_full(lock-ref_name, mustexist ? RESOLVE_REF_READING : 0, - lock-old_sha1, NULL)) { + lock-old_oid.hash, NULL)) { int save_errno = errno; error(Can't verify ref %s, lock-ref_name); unlock_ref(lock); errno = save_errno; return NULL; } - if (hashcmp(lock-old_sha1, old_sha1)) { + if (hashcmp(lock-old_oid.hash, old_sha1)) { error(Ref %s is at %s but expected %s, lock-ref_name, - sha1_to_hex(lock-old_sha1), sha1_to_hex(old_sha1)); + oid_to_hex(lock-old_oid), sha1_to_hex(old_sha1)); unlock_ref(lock); errno = EBUSY; return NULL; @@ -2382,7 +2382,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname, } refname = resolve_ref_unsafe(refname, resolve_flags, -lock-old_sha1, type); +lock-old_oid.hash, type); if (!refname errno == EISDIR) { /* we are trying to lock foo but we used to * have foo/bar which now does not exist; @@ -2401,7 +2401,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname, goto error_return; } refname = resolve_ref_unsafe(orig_refname, resolve_flags, -lock-old_sha1, type); +lock-old_oid.hash, type); } if (type_p) *type_p = type; @@ -2421,7 +2421,7 @@ static struct ref_lock *lock_ref_sha1_basic(const char *refname, * refname, nor a packed ref whose name is a proper prefix of * our refname. */ - if (is_null_sha1(lock-old_sha1) + if (is_null_oid(lock-old_oid) verify_refname_available(refname, extras, skip, get_packed_refs(ref_cache), err)) { last_errno = ENOTDIR; @@ -2944,7 +2944,7 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms strbuf_release(err); goto rollback; } - hashcpy(lock-old_sha1, orig_sha1); + hashcpy(lock-old_oid.hash, orig_sha1); if (write_ref_to_lockfile(lock, orig_sha1) || commit_ref_update(lock, orig_sha1, logmsg)) { @@ -3199,9 +3199,9 @@ static int commit_ref_update(struct ref_lock *lock, const unsigned char *sha1, const char *logmsg) { clear_loose_ref_cache(ref_cache); - if (log_ref_write(lock-ref_name, lock-old_sha1, sha1, logmsg) 0 || + if (log_ref_write(lock-ref_name, lock-old_oid.hash, sha1, logmsg) 0 || (strcmp(lock-ref_name, lock-orig_ref_name) -log_ref_write(lock-orig_ref_name, lock-old_sha1, sha1, logmsg) 0)) { +log_ref_write(lock-orig_ref_name, lock-old_oid.hash, sha1, logmsg) 0)) { unlock_ref(lock); return -1; } @@ -3225,7 +3225,7 @@ static int commit_ref_update(struct ref_lock *lock, head_sha1, head_flag); if (head_ref (head_flag REF_ISSYMREF) !strcmp(head_ref, lock-ref_name)) - log_ref_write(HEAD, lock-old_sha1, sha1, logmsg); + log_ref_write(HEAD, lock-old_oid.hash, sha1, logmsg); } if (commit_ref(lock)) { error(Couldn't set %s, lock-ref_name); @@ -3923,7 +3923,7 @@ int ref_transaction_commit(struct ref_transaction *transaction, (update-flags REF_NODEREF)); if (!overwriting_symref - !hashcmp(update-lock-old_sha1, update-new_sha1)) { + !hashcmp(update-lock-old_oid.hash, update-new_sha1)) { /* * The reference already has the desired * value, so we don't need to write it. -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More
[PATCH v3 46/56] upload-pack: rewrite functions to take object_id arguments
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- upload-pack.c | 32 ++-- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 8268037..929284f 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -681,9 +681,9 @@ static void receive_needs(void) } /* return non-zero if the ref is hidden, otherwise 0 */ -static int mark_our_ref(const char *refname, const unsigned char *sha1) +static int mark_our_ref(const char *refname, const struct object_id *oid) { - struct object *o = lookup_unknown_object(sha1); + struct object *o = lookup_unknown_object(oid-hash); if (ref_is_hidden(refname)) { o-flags |= HIDDEN_REF; @@ -693,9 +693,10 @@ static int mark_our_ref(const char *refname, const unsigned char *sha1) return 0; } -static int check_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int check_ref(const char *refname, const struct object_id *oid, +int flag, void *cb_data) { - mark_our_ref(refname, sha1); + mark_our_ref(refname, oid); return 0; } @@ -709,7 +710,8 @@ static void format_symref_info(struct strbuf *buf, struct string_list *symref) strbuf_addf(buf, symref=%s:%s, item-string, (char *)item-util); } -static int send_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int send_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { static const char *capabilities = multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress @@ -717,7 +719,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo const char *refname_nons = strip_namespace(refname); unsigned char peeled[20]; - if (mark_our_ref(refname, sha1)) + if (mark_our_ref(refname, oid)) return 0; if (capabilities) { @@ -725,7 +727,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo format_symref_info(symref_info, cb_data); packet_write(1, %s %s%c%s%s%s%s agent=%s\n, -sha1_to_hex(sha1), refname_nons, +oid_to_hex(oid), refname_nons, 0, capabilities, allow_tip_sha1_in_want ? allow-tip-sha1-in-want : , stateless_rpc ? no-done : , @@ -733,7 +735,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo git_user_agent_sanitized()); strbuf_release(symref_info); } else { - packet_write(1, %s %s\n, sha1_to_hex(sha1), refname_nons); + packet_write(1, %s %s\n, oid_to_hex(oid), refname_nons); } capabilities = NULL; if (!peel_ref(refname, peeled)) @@ -765,20 +767,14 @@ static void upload_pack(void) head_ref_namespaced(find_symref, symref); if (advertise_refs || !stateless_rpc) { - struct each_ref_fn_sha1_adapter wrapped_send_ref = - {send_ref, symref}; - reset_timeout(); - head_ref_namespaced(each_ref_fn_adapter, wrapped_send_ref); - for_each_namespaced_ref(each_ref_fn_adapter, wrapped_send_ref); + head_ref_namespaced(send_ref, symref); + for_each_namespaced_ref(send_ref, symref); advertise_shallow_grafts(1); packet_flush(1); } else { - struct each_ref_fn_sha1_adapter wrapped_check_ref = - {check_ref, NULL}; - - head_ref_namespaced(each_ref_fn_adapter, wrapped_check_ref); - for_each_namespaced_ref(each_ref_fn_adapter, wrapped_check_ref); + head_ref_namespaced(check_ref, NULL); + for_each_namespaced_ref(check_ref, NULL); } string_list_clear(symref, 1); if (advertise_refs) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 49/56] clear_marks(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- fetch-pack.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 5380b1b..1e875cf 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -70,9 +70,10 @@ static int rev_list_insert_ref(const char *refname, const unsigned char *sha1, i return 0; } -static int clear_marks(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int clear_marks(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { - struct object *o = deref_tag(parse_object(sha1), refname, 0); + struct object *o = deref_tag(parse_object(oid-hash), refname, 0); if (o o-type == OBJ_COMMIT) clear_commit_marks((struct commit *)o, @@ -261,12 +262,8 @@ static int find_common(struct fetch_pack_args *args, if (args-stateless_rpc multi_ack == 1) die(--stateless-rpc requires multi_ack_detailed); - if (marked) { - struct each_ref_fn_sha1_adapter wrapped_clear_marks = - {clear_marks, NULL}; - - for_each_ref(each_ref_fn_adapter, wrapped_clear_marks); - } + if (marked) + for_each_ref(clear_marks, NULL); marked = 1; for_each_ref(each_ref_fn_adapter, wrapped_rev_list_insert_ref); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 53/56] rev_list_insert_ref(): remove unneeded arguments
From: Michael Haggerty mhag...@alum.mit.edu Now that the function is not being used as an each_ref_sha1_fn, we can delete the unused arguments in its signature. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- fetch-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 28c54c3..a1dcb27 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -60,7 +60,7 @@ static void rev_list_push(struct commit *commit, int mark) } } -static int rev_list_insert_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int rev_list_insert_ref(const char *refname, const unsigned char *sha1) { struct object *o = deref_tag(parse_object(sha1), refname, 0); @@ -73,7 +73,7 @@ static int rev_list_insert_ref(const char *refname, const unsigned char *sha1, i static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid, int flag, void *cb_data) { - return rev_list_insert_ref(refname, oid-hash, flag, cb_data); + return rev_list_insert_ref(refname, oid-hash); } static int clear_marks(const char *refname, const struct object_id *oid, @@ -233,7 +233,7 @@ static void send_request(struct fetch_pack_args *args, static void insert_one_alternate_ref(const struct ref *ref, void *unused) { - rev_list_insert_ref(NULL, ref-old_sha1, 0, NULL); + rev_list_insert_ref(NULL, ref-old_sha1); } #define INITIAL_FLUSH 16 -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 41/56] submodule: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- submodule.c | 22 +++--- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/submodule.c b/submodule.c index f0f34b6..e4c59df 100644 --- a/submodule.c +++ b/submodule.c @@ -422,20 +422,18 @@ void set_config_fetch_recurse_submodules(int value) config_fetch_recurse_submodules = value; } -static int has_remote(const char *refname, const unsigned char *sha1, int flags, void *cb_data) +static int has_remote(const char *refname, const struct object_id *oid, + int flags, void *cb_data) { return 1; } static int submodule_needs_pushing(const char *path, const unsigned char sha1[20]) { - struct each_ref_fn_sha1_adapter wrapped_has_remote = - {has_remote, NULL}; - if (add_submodule_odb(path) || !lookup_commit_reference(sha1)) return 0; - if (for_each_remote_ref_submodule(path, each_ref_fn_adapter, wrapped_has_remote) 0) { + if (for_each_remote_ref_submodule(path, has_remote, NULL) 0) { struct child_process cp = CHILD_PROCESS_INIT; const char *argv[] = {rev-list, NULL, --not, --remotes, -n, 1 , NULL}; struct strbuf buf = STRBUF_INIT; @@ -522,13 +520,10 @@ int find_unpushed_submodules(unsigned char new_sha1[20], static int push_submodule(const char *path) { - struct each_ref_fn_sha1_adapter wrapped_has_remote = - {has_remote, NULL}; - if (add_submodule_odb(path)) return 1; - if (for_each_remote_ref_submodule(path, each_ref_fn_adapter, wrapped_has_remote) 0) { + if (for_each_remote_ref_submodule(path, has_remote, NULL) 0) { struct child_process cp = CHILD_PROCESS_INIT; const char *argv[] = {push, NULL}; @@ -622,20 +617,17 @@ static void submodule_collect_changed_cb(struct diff_queue_struct *q, } } -static int add_sha1_to_array(const char *ref, const unsigned char *sha1, +static int add_sha1_to_array(const char *ref, const struct object_id *oid, int flags, void *data) { - sha1_array_append(data, sha1); + sha1_array_append(data, oid-hash); return 0; } void check_for_new_submodule_commits(unsigned char new_sha1[20]) { if (!initialized_fetch_ref_tips) { - struct each_ref_fn_sha1_adapter wrapped_add_sha1_to_array = - {add_sha1_to_array, ref_tips_before_fetch}; - - for_each_ref(each_ref_fn_adapter, wrapped_add_sha1_to_array); + for_each_ref(add_sha1_to_array, ref_tips_before_fetch); initialized_fetch_ref_tips = 1; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 28/56] append_similar_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- help.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/help.c b/help.c index f813093..6f3415b 100644 --- a/help.c +++ b/help.c @@ -407,7 +407,7 @@ struct similar_ref_cb { struct string_list *similar_refs; }; -static int append_similar_ref(const char *refname, const unsigned char *sha1, +static int append_similar_ref(const char *refname, const struct object_id *oid, int flags, void *cb_data) { struct similar_ref_cb *cb = (struct similar_ref_cb *)(cb_data); @@ -425,12 +425,10 @@ static struct string_list guess_refs(const char *ref) { struct similar_ref_cb ref_cb; struct string_list similar_refs = STRING_LIST_INIT_NODUP; - struct each_ref_fn_sha1_adapter wrapped_append_similar_ref = - {append_similar_ref, ref_cb}; ref_cb.base_ref = ref; ref_cb.similar_refs = similar_refs; - for_each_ref(each_ref_fn_adapter, wrapped_append_similar_ref); + for_each_ref(append_similar_ref, ref_cb); return similar_refs; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 47/56] send_ref(): convert local variable peeled to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- upload-pack.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/upload-pack.c b/upload-pack.c index 929284f..1cb9a94 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -717,7 +717,7 @@ static int send_ref(const char *refname, const struct object_id *oid, side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed; const char *refname_nons = strip_namespace(refname); - unsigned char peeled[20]; + struct object_id peeled; if (mark_our_ref(refname, oid)) return 0; @@ -738,8 +738,8 @@ static int send_ref(const char *refname, const struct object_id *oid, packet_write(1, %s %s\n, oid_to_hex(oid), refname_nons); } capabilities = NULL; - if (!peel_ref(refname, peeled)) - packet_write(1, %s %s^{}\n, sha1_to_hex(peeled), refname_nons); + if (!peel_ref(refname, peeled.hash)) + packet_write(1, %s %s^{}\n, oid_to_hex(peeled), refname_nons); return 0; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 52/56] rev_list_insert_ref_oid(): new function, taking an object_oid
From: Michael Haggerty mhag...@alum.mit.edu This function can be used with for_each_ref() without having to be wrapped. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- fetch-pack.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/fetch-pack.c b/fetch-pack.c index 13a5000..28c54c3 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -70,6 +70,12 @@ static int rev_list_insert_ref(const char *refname, const unsigned char *sha1, i return 0; } +static int rev_list_insert_ref_oid(const char *refname, const struct object_id *oid, + int flag, void *cb_data) +{ + return rev_list_insert_ref(refname, oid-hash, flag, cb_data); +} + static int clear_marks(const char *refname, const struct object_id *oid, int flag, void *cb_data) { @@ -257,8 +263,6 @@ static int find_common(struct fetch_pack_args *args, int got_ready = 0; struct strbuf req_buf = STRBUF_INIT; size_t state_len = 0; - struct each_ref_fn_sha1_adapter wrapped_rev_list_insert_ref = - {rev_list_insert_ref, NULL}; if (args-stateless_rpc multi_ack == 1) die(--stateless-rpc requires multi_ack_detailed); @@ -266,7 +270,7 @@ static int find_common(struct fetch_pack_args *args, for_each_ref(clear_marks, NULL); marked = 1; - for_each_ref(each_ref_fn_adapter, wrapped_rev_list_insert_ref); + for_each_ref(rev_list_insert_ref_oid, NULL); for_each_alternate_ref(insert_one_alternate_ref, NULL); fetching = 0; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 39/56] handle_one_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- sha1_name.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 1aad0a322..1cb8108 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -831,11 +831,11 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1, unsigned l /* Remember to update object flag allocation in object.h */ #define ONELINE_SEEN (1u20) -static int handle_one_ref(const char *path, - const unsigned char *sha1, int flag, void *cb_data) +static int handle_one_ref(const char *path, const struct object_id *oid, + int flag, void *cb_data) { struct commit_list **list = cb_data; - struct object *object = parse_object(sha1); + struct object *object = parse_object(oid-hash); if (!object) return 0; if (object-type == OBJ_TAG) { @@ -1371,10 +1371,8 @@ static int get_sha1_with_context_1(const char *name, int pos; if (!only_to_die namelen 2 name[1] == '/') { struct commit_list *list = NULL; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, list}; - for_each_ref(each_ref_fn_adapter, wrapped_handle_one_ref); + for_each_ref(handle_one_ref, list); commit_list_sort_by_date(list); return get_sha1_oneline(name + 2, sha1, list); } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 43/56] write_one_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- transport.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/transport.c b/transport.c index df87386..40692f8 100644 --- a/transport.c +++ b/transport.c @@ -278,8 +278,8 @@ static int fetch_objs_via_rsync(struct transport *transport, return run_command(rsync); } -static int write_one_ref(const char *name, const unsigned char *sha1, - int flags, void *data) +static int write_one_ref(const char *name, const struct object_id *oid, +int flags, void *data) { struct strbuf *buf = data; int len = buf-len; @@ -291,7 +291,7 @@ static int write_one_ref(const char *name, const unsigned char *sha1, strbuf_addstr(buf, name); if (safe_create_leading_directories(buf-buf) || - write_file(buf-buf, 0, %s\n, sha1_to_hex(sha1))) + write_file(buf-buf, 0, %s\n, oid_to_hex(oid))) return error(problems writing temporary file %s: %s, buf-buf, strerror(errno)); strbuf_setlen(buf, len); @@ -310,7 +310,7 @@ static int write_refs_to_temp_dir(struct strbuf *temp_dir, if (dwim_ref(refspec[i], strlen(refspec[i]), oid.hash, ref) != 1) return error(Could not get ref %s, refspec[i]); - if (write_one_ref(ref, oid.hash, 0, temp_dir)) { + if (write_one_ref(ref, oid, 0, temp_dir)) { free(ref); return -1; } @@ -363,10 +363,7 @@ static int rsync_transport_push(struct transport *transport, strbuf_addch(temp_dir, '/'); if (flags TRANSPORT_PUSH_ALL) { - struct each_ref_fn_sha1_adapter wrapped_write_one_ref = - {write_one_ref, temp_dir}; - - if (for_each_ref(each_ref_fn_adapter, wrapped_write_one_ref)) + if (for_each_ref(write_one_ref, temp_dir)) return -1; } else if (write_refs_to_temp_dir(temp_dir, refspec_nr, refspec)) return -1; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 34/56] add_one_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- reachable.c | 11 +-- 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/reachable.c b/reachable.c index acac86a..9cff25b 100644 --- a/reachable.c +++ b/reachable.c @@ -22,9 +22,10 @@ static void update_progress(struct connectivity_progress *cp) display_progress(cp-progress, cp-count); } -static int add_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int add_one_ref(const char *path, const struct object_id *oid, + int flag, void *cb_data) { - struct object *object = parse_object_or_die(sha1, path); + struct object *object = parse_object_or_die(oid-hash, path); struct rev_info *revs = (struct rev_info *)cb_data; add_pending_object(revs, object, ); @@ -155,8 +156,6 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog, struct progress *progress) { struct connectivity_progress cp; - struct each_ref_fn_sha1_adapter wrapped_add_one_ref = - {add_one_ref, revs}; /* * Set up revision parsing, and mark us as being interested @@ -170,10 +169,10 @@ void mark_reachable_objects(struct rev_info *revs, int mark_reflog, add_index_objects_to_pending(revs, 0); /* Add all external refs */ - for_each_ref(each_ref_fn_adapter, wrapped_add_one_ref); + for_each_ref(add_one_ref, revs); /* detached HEAD is not included in the list above */ - head_ref(each_ref_fn_adapter, wrapped_add_one_ref); + head_ref(add_one_ref, revs); /* Add all reflog info */ if (mark_reflog) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 00/56] Convert parts of refs.c to struct object_id
brian m. carlson sand...@crustytoothpaste.net writes: Changes from v2: * Adopt Michael Haggerty's patch series that uses an adapter function. * Squash some of these patches together where it makes sense in order to reduce the quantity of patches. This does only slightly more than my original series, just in a different way, with a larger number of much smaller patches. If the quantity of patches is too large for people's tastes, I can do a v4 based off of v2 that has less of this problem. Thanks. I think these all look good. And clashes with in-flight topics seem to be manageable ;-) [PATCH 01/56] was authored by you but has Michael's sign-off, which looked somewhat odd to me, though. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 01/56] refs: convert struct ref_entry to use struct object_id
Signed-off-by: brian m. carlson sand...@crustytoothpaste.net Signed-off-by: Michael Haggerty mhag...@alum.mit.edu --- refs.c | 44 ++-- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/refs.c b/refs.c index 8480d8d..9ca4651 100644 --- a/refs.c +++ b/refs.c @@ -161,7 +161,7 @@ struct ref_value { * null. If REF_ISSYMREF, then this is the name of the object * referred to by the last reference in the symlink chain. */ - unsigned char sha1[20]; + struct object_id oid; /* * If REF_KNOWS_PEELED, then this field holds the peeled value @@ -169,7 +169,7 @@ struct ref_value { * be peelable. See the documentation for peel_ref() for an * exact definition of peelable. */ - unsigned char peeled[20]; + struct object_id peeled; }; struct ref_cache; @@ -351,8 +351,8 @@ static struct ref_entry *create_ref_entry(const char *refname, die(Reference has invalid format: '%s', refname); len = strlen(refname) + 1; ref = xmalloc(sizeof(struct ref_entry) + len); - hashcpy(ref-u.value.sha1, sha1); - hashclr(ref-u.value.peeled); + hashcpy(ref-u.value.oid.hash, sha1); + oidclr(ref-u.value.peeled); memcpy(ref-name, refname, len); ref-flag = flag; return ref; @@ -626,7 +626,7 @@ static int is_dup_ref(const struct ref_entry *ref1, const struct ref_entry *ref2 /* This is impossible by construction */ die(Reference directory conflict: %s, ref1-name); - if (hashcmp(ref1-u.value.sha1, ref2-u.value.sha1)) + if (oidcmp(ref1-u.value.oid, ref2-u.value.oid)) die(Duplicated ref, and SHA1s don't match: %s, ref1-name); warning(Duplicated ref: %s, ref1-name); @@ -674,7 +674,7 @@ static int ref_resolves_to_object(struct ref_entry *entry) { if (entry-flag REF_ISBROKEN) return 0; - if (!has_sha1_file(entry-u.value.sha1)) { + if (!has_sha1_file(entry-u.value.oid.hash)) { error(%s does not point to a valid object!, entry-name); return 0; } @@ -722,7 +722,7 @@ static int do_one_ref(struct ref_entry *entry, void *cb_data) /* Store the old value, in case this is a recursive call: */ old_current_ref = current_ref; current_ref = entry; - retval = data-fn(entry-name + data-trim, entry-u.value.sha1, + retval = data-fn(entry-name + data-trim, entry-u.value.oid.hash, entry-flag, data-cb_data); current_ref = old_current_ref; return retval; @@ -1258,7 +1258,7 @@ static void read_packed_refs(FILE *f, struct ref_dir *dir) line.len == PEELED_LINE_LENGTH line.buf[PEELED_LINE_LENGTH - 1] == '\n' !get_sha1_hex(line.buf + 1, sha1)) { - hashcpy(last-u.value.peeled, sha1); + hashcpy(last-u.value.peeled.hash, sha1); /* * Regardless of what the file header said, * we definitely know the value of *this* @@ -1439,7 +1439,7 @@ static int resolve_gitlink_packed_ref(struct ref_cache *refs, if (ref == NULL) return -1; - hashcpy(sha1, ref-u.value.sha1); + hashcpy(sha1, ref-u.value.oid.hash); return 0; } @@ -1526,7 +1526,7 @@ static int resolve_missing_loose_ref(const char *refname, */ entry = get_packed_ref(refname); if (entry) { - hashcpy(sha1, entry-u.value.sha1); + hashcpy(sha1, entry-u.value.oid.hash); if (flags) *flags |= REF_ISPACKED; return 0; @@ -1836,9 +1836,9 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel) if (entry-flag REF_KNOWS_PEELED) { if (repeel) { entry-flag = ~REF_KNOWS_PEELED; - hashclr(entry-u.value.peeled); + oidclr(entry-u.value.peeled); } else { - return is_null_sha1(entry-u.value.peeled) ? + return is_null_oid(entry-u.value.peeled) ? PEEL_NON_TAG : PEEL_PEELED; } } @@ -1847,7 +1847,7 @@ static enum peel_status peel_entry(struct ref_entry *entry, int repeel) if (entry-flag REF_ISSYMREF) return PEEL_IS_SYMREF; - status = peel_object(entry-u.value.sha1, entry-u.value.peeled); + status = peel_object(entry-u.value.oid.hash, entry-u.value.peeled.hash); if (status == PEEL_PEELED || status == PEEL_NON_TAG) entry-flag |= REF_KNOWS_PEELED; return status; @@ -1862,7 +1862,7 @@ int peel_ref(const char *refname, unsigned char *sha1) ||
[PATCH v3 25/56] builtin/show-ref: rewrite to use object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-ref.c | 33 +++-- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 8e25536..18f84fb 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -17,16 +17,17 @@ static int deref_tags, show_head, tags_only, heads_only, found_match, verify, static const char **pattern; static const char *exclude_existing_arg; -static void show_one(const char *refname, const unsigned char *sha1) +static void show_one(const char *refname, const struct object_id *oid) { - const char *hex = find_unique_abbrev(sha1, abbrev); + const char *hex = find_unique_abbrev(oid-hash, abbrev); if (hash_only) printf(%s\n, hex); else printf(%s %s\n, hex, refname); } -static int show_ref(const char *refname, const unsigned char *sha1, int flag, void *cbdata) +static int show_ref(const char *refname, const struct object_id *oid, + int flag, void *cbdata) { const char *hex; unsigned char peeled[20]; @@ -69,14 +70,14 @@ match: * detect and return error if the repository is corrupt and * ref points at a nonexistent object. */ - if (!has_sha1_file(sha1)) + if (!has_sha1_file(oid-hash)) die(git show-ref: bad ref %s (%s), refname, - sha1_to_hex(sha1)); + oid_to_hex(oid)); if (quiet) return 0; - show_one(refname, sha1); + show_one(refname, oid); if (!deref_tags) return 0; @@ -88,7 +89,8 @@ match: return 0; } -static int add_existing(const char *refname, const unsigned char *sha1, int flag, void *cbdata) +static int add_existing(const char *refname, const struct object_id *oid, + int flag, void *cbdata) { struct string_list *list = (struct string_list *)cbdata; string_list_insert(list, refname); @@ -109,10 +111,8 @@ static int exclude_existing(const char *match) static struct string_list existing_refs = STRING_LIST_INIT_DUP; char buf[1024]; int matchlen = match ? strlen(match) : 0; - struct each_ref_fn_sha1_adapter wrapped_add_existing = - {add_existing, existing_refs}; - for_each_ref(each_ref_fn_adapter, wrapped_add_existing); + for_each_ref(add_existing, existing_refs); while (fgets(buf, sizeof(buf), stdin)) { char *ref; int len = strlen(buf); @@ -193,9 +193,6 @@ static const struct option show_ref_options[] = { int cmd_show_ref(int argc, const char **argv, const char *prefix) { - struct each_ref_fn_sha1_adapter wrapped_show_ref = - {show_ref, NULL}; - if (argc == 2 !strcmp(argv[1], -h)) usage_with_options(show_ref_usage, show_ref_options); @@ -213,12 +210,12 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) if (!pattern) die(--verify requires a reference); while (*pattern) { - unsigned char sha1[20]; + struct object_id oid; if (starts_with(*pattern, refs/) - !read_ref(*pattern, sha1)) { + !read_ref(*pattern, oid.hash)) { if (!quiet) - show_one(*pattern, sha1); + show_one(*pattern, oid); } else if (!quiet) die('%s' - not a valid ref, *pattern); @@ -230,8 +227,8 @@ int cmd_show_ref(int argc, const char **argv, const char *prefix) } if (show_head) - head_ref(each_ref_fn_adapter, wrapped_show_ref); - for_each_ref(each_ref_fn_adapter, wrapped_show_ref); + head_ref(show_ref, NULL); + for_each_ref(show_ref, NULL); if (!found_match) { if (verify !quiet) die(No match); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 17/56] builtin/remote: rewrite functions to take object_id arguments
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/remote.c | 21 - 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index ab39fea..f4a6ec9 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -554,20 +554,20 @@ struct rename_info { }; static int read_remote_branches(const char *refname, - const unsigned char *sha1, int flags, void *cb_data) + const struct object_id *oid, int flags, void *cb_data) { struct rename_info *rename = cb_data; struct strbuf buf = STRBUF_INIT; struct string_list_item *item; int flag; - unsigned char orig_sha1[20]; + struct object_id orig_oid; const char *symref; strbuf_addf(buf, refs/remotes/%s/, rename-old); if (starts_with(refname, buf.buf)) { item = string_list_append(rename-remote_branches, xstrdup(refname)); symref = resolve_ref_unsafe(refname, RESOLVE_REF_READING, - orig_sha1, flag); + orig_oid.hash, flag); if (flag REF_ISSYMREF) item-util = xstrdup(symref); else @@ -620,8 +620,6 @@ static int mv(int argc, const char **argv) struct string_list remote_branches = STRING_LIST_INIT_NODUP; struct rename_info rename; int i, refspec_updated = 0; - struct each_ref_fn_sha1_adapter wrapped_read_remote_branches = - {read_remote_branches, rename}; if (argc != 3) usage_with_options(builtin_remote_rename_usage, options); @@ -699,13 +697,13 @@ static int mv(int argc, const char **argv) * First remove symrefs, then rename the rest, finally create * the new symrefs. */ - for_each_ref(each_ref_fn_adapter, wrapped_read_remote_branches); + for_each_ref(read_remote_branches, rename); for (i = 0; i remote_branches.nr; i++) { struct string_list_item *item = remote_branches.items + i; int flag = 0; - unsigned char sha1[20]; + struct object_id oid; - read_ref_full(item-string, RESOLVE_REF_READING, sha1, flag); + read_ref_full(item-string, RESOLVE_REF_READING, oid.hash, flag); if (!(flag REF_ISSYMREF)) continue; if (delete_ref(item-string, NULL, REF_NODEREF)) @@ -866,7 +864,7 @@ static void free_remote_ref_states(struct ref_states *states) } static int append_ref_to_tracked_list(const char *refname, - const unsigned char *sha1, int flags, void *cb_data) + const struct object_id *oid, int flags, void *cb_data) { struct ref_states *states = cb_data; struct refspec refspec; @@ -909,10 +907,7 @@ static int get_remote_ref_states(const char *name, if (query GET_PUSH_REF_STATES) get_push_ref_states(remote_refs, states); } else { - struct each_ref_fn_sha1_adapter wrapped_append_ref_to_tracked_list = - {append_ref_to_tracked_list, states}; - - for_each_ref(each_ref_fn_adapter, wrapped_append_ref_to_tracked_list); + for_each_ref(append_ref_to_tracked_list, states); string_list_sort(states-tracked); get_push_ref_states_noquery(states); } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 14/56] builtin/reflog: rewrite ref functions to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/reflog.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index 1163dd6..c2eb8ff 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -313,14 +313,14 @@ static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1, return 0; } -static int push_tip_to_list(const char *refname, const unsigned char *sha1, +static int push_tip_to_list(const char *refname, const struct object_id *oid, int flags, void *cb_data) { struct commit_list **list = cb_data; struct commit *tip_commit; if (flags REF_ISSYMREF) return 0; - tip_commit = lookup_commit_reference_gently(sha1, 1); + tip_commit = lookup_commit_reference_gently(oid-hash, 1); if (!tip_commit) return 0; commit_list_insert(tip_commit, list); @@ -352,10 +352,8 @@ static void reflog_expiry_prepare(const char *refname, if (cb-unreachable_expire_kind != UE_ALWAYS) { if (cb-unreachable_expire_kind == UE_HEAD) { struct commit_list *elem; - struct each_ref_fn_sha1_adapter wrapped_push_tip_to_list = - {push_tip_to_list, cb-tips}; - for_each_ref(each_ref_fn_adapter, wrapped_push_tip_to_list); + for_each_ref(push_tip_to_list, cb-tips); for (elem = cb-tips; elem; elem = elem-next) commit_list_insert(elem-item, cb-mark_list); } else { @@ -382,14 +380,14 @@ static void reflog_expiry_cleanup(void *cb_data) } } -static int collect_reflog(const char *ref, const unsigned char *sha1, int unused, void *cb_data) +static int collect_reflog(const char *ref, const struct object_id *oid, int unused, void *cb_data) { struct collected_reflog *e; struct collect_reflog_cb *cb = cb_data; size_t namelen = strlen(ref); e = xmalloc(sizeof(*e) + namelen + 1); - hashcpy(e-sha1, sha1); + hashcpy(e-sha1, oid-hash); memcpy(e-reflog, ref, namelen + 1); ALLOC_GROW(cb-e, cb-nr + 1, cb-alloc); cb-e[cb-nr++] = e; @@ -591,11 +589,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) if (do_all) { struct collect_reflog_cb collected; int i; - struct each_ref_fn_sha1_adapter wrapped_collect_reflog = - {collect_reflog, collected}; memset(collected, 0, sizeof(collected)); - for_each_reflog(each_ref_fn_adapter, wrapped_collect_reflog); + for_each_reflog(collect_reflog, collected); for (i = 0; i collected.nr; i++) { struct collected_reflog *e = collected.e[i]; set_reflog_expiry_param(cb.cmd, explicit_expiry, e-reflog); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 23/56] cmd_show_branch(): fix error message
From: Michael Haggerty mhag...@alum.mit.edu We need to convert the SHA-1 to hexadecimal before printing it. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-branch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 826d9fa..323f857 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -846,7 +846,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) commit = lookup_commit_reference(revkey.hash); if (!commit) die(cannot find commit %s (%s), - ref_name[num_rev], revkey.hash); + ref_name[num_rev], oid_to_hex(revkey)); parse_commit(commit); mark_seen(commit, seen); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 38/56] add_info_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- server-info.c | 12 +--- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server-info.c b/server-info.c index 317dda8..c82e9ee 100644 --- a/server-info.c +++ b/server-info.c @@ -47,14 +47,15 @@ out: return ret; } -static int add_info_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int add_info_ref(const char *path, const struct object_id *oid, + int flag, void *cb_data) { FILE *fp = cb_data; - struct object *o = parse_object(sha1); + struct object *o = parse_object(oid-hash); if (!o) return -1; - if (fprintf(fp, %s %s\n, sha1_to_hex(sha1), path) 0) + if (fprintf(fp, %s %s\n, oid_to_hex(oid), path) 0) return -1; if (o-type == OBJ_TAG) { @@ -69,10 +70,7 @@ static int add_info_ref(const char *path, const unsigned char *sha1, int flag, v static int generate_info_refs(FILE *fp) { - struct each_ref_fn_sha1_adapter wrapped_add_info_ref = - {add_info_ref, fp}; - - return for_each_ref(each_ref_fn_adapter, wrapped_add_info_ref); + return for_each_ref(add_info_ref, fp); } static int update_info_refs(int force) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 24/56] fsck: change functions to use object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/fsck.c | 29 + 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/builtin/fsck.c b/builtin/fsck.c index 48d0c2e..4e8e2ee 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -25,7 +25,7 @@ static int include_reflogs = 1; static int check_full = 1; static int check_strict; static int keep_cache_objects; -static unsigned char head_sha1[20]; +static struct object_id head_oid; static const char *head_points_at; static int errors_found; static int write_lost_and_found; @@ -476,19 +476,21 @@ static int fsck_handle_reflog_ent(unsigned char *osha1, unsigned char *nsha1, return 0; } -static int fsck_handle_reflog(const char *logname, const unsigned char *sha1, int flag, void *cb_data) +static int fsck_handle_reflog(const char *logname, const struct object_id *oid, + int flag, void *cb_data) { for_each_reflog_ent(logname, fsck_handle_reflog_ent, NULL); return 0; } -static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int fsck_handle_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { struct object *obj; - obj = parse_object(sha1); + obj = parse_object(oid-hash); if (!obj) { - error(%s: invalid sha1 pointer %s, refname, sha1_to_hex(sha1)); + error(%s: invalid sha1 pointer %s, refname, oid_to_hex(oid)); errors_found |= ERROR_REACHABLE; /* We'll continue with the rest despite the error.. */ return 0; @@ -504,16 +506,11 @@ static int fsck_handle_ref(const char *refname, const unsigned char *sha1, int f static void get_default_heads(void) { - struct each_ref_fn_sha1_adapter wrapped_fsck_handle_ref = - {fsck_handle_ref, NULL}; - struct each_ref_fn_sha1_adapter wrapped_fsck_handle_reflog = - {fsck_handle_reflog, NULL}; - - if (head_points_at !is_null_sha1(head_sha1)) - fsck_handle_ref(HEAD, head_sha1, 0, NULL); - for_each_rawref(each_ref_fn_adapter, wrapped_fsck_handle_ref); + if (head_points_at !is_null_oid(head_oid)) + fsck_handle_ref(HEAD, head_oid, 0, NULL); + for_each_rawref(fsck_handle_ref, NULL); if (include_reflogs) - for_each_reflog(each_ref_fn_adapter, wrapped_fsck_handle_reflog); + for_each_reflog(fsck_handle_reflog, NULL); /* * Not having any default heads isn't really fatal, but @@ -561,7 +558,7 @@ static int fsck_head_link(void) if (verbose) fprintf(stderr, Checking HEAD link\n); - head_points_at = resolve_ref_unsafe(HEAD, 0, head_sha1, flag); + head_points_at = resolve_ref_unsafe(HEAD, 0, head_oid.hash, flag); if (!head_points_at) return error(Invalid HEAD); if (!strcmp(head_points_at, HEAD)) @@ -570,7 +567,7 @@ static int fsck_head_link(void) else if (!starts_with(head_points_at, refs/heads/)) return error(HEAD points to something strange (%s), head_points_at); - if (is_null_sha1(head_sha1)) { + if (is_null_oid(head_oid)) { if (null_is_error) return error(HEAD: detached HEAD points at nothing); fprintf(stderr, notice: HEAD points to an unborn branch (%s)\n, -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 30/56] show_head_ref(): convert local variable unused to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- http-backend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http-backend.c b/http-backend.c index a2d388d..55353ad 100644 --- a/http-backend.c +++ b/http-backend.c @@ -408,10 +408,10 @@ static int show_head_ref(const char *refname, const struct object_id *oid, struct strbuf *buf = cb_data; if (flag REF_ISSYMREF) { - unsigned char unused[20]; + struct object_id unused; const char *target = resolve_ref_unsafe(refname, RESOLVE_REF_READING, - unused, NULL); + unused.hash, NULL); const char *target_nons = strip_namespace(target); strbuf_addf(buf, ref: %s\n, target_nons); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 40/56] shallow: rewrite functions to take object_id arguments
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- shallow.c | 29 +++-- 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/shallow.c b/shallow.c index 9488edc..257d811 100644 --- a/shallow.c +++ b/shallow.c @@ -475,11 +475,10 @@ static void paint_down(struct paint_info *info, const unsigned char *sha1, free(tmp); } -static int mark_uninteresting(const char *refname, - const unsigned char *sha1, +static int mark_uninteresting(const char *refname, const struct object_id *oid, int flags, void *cb_data) { - struct commit *commit = lookup_commit_reference_gently(sha1, 1); + struct commit *commit = lookup_commit_reference_gently(oid-hash, 1); if (!commit) return 0; commit-object.flags |= UNINTERESTING; @@ -512,8 +511,6 @@ void assign_shallow_commits_to_refs(struct shallow_info *info, unsigned int i, nr; int *shallow, nr_shallow = 0; struct paint_info pi; - struct each_ref_fn_sha1_adapter wrapped_mark_uninteresting = - {mark_uninteresting, NULL}; trace_printf_key(trace_shallow, shallow: assign_shallow_commits_to_refs\n); shallow = xmalloc(sizeof(*shallow) * (info-nr_ours + info-nr_theirs)); @@ -544,8 +541,8 @@ void assign_shallow_commits_to_refs(struct shallow_info *info, * connect to old refs. If not (e.g. force ref updates) it'll * have to go down to the current shallow commits. */ - head_ref(each_ref_fn_adapter, wrapped_mark_uninteresting); - for_each_ref(each_ref_fn_adapter, wrapped_mark_uninteresting); + head_ref(mark_uninteresting, NULL); + for_each_ref(mark_uninteresting, NULL); /* Mark potential bottoms so we won't go out of bound */ for (i = 0; i nr_shallow; i++) { @@ -586,12 +583,12 @@ struct commit_array { int nr, alloc; }; -static int add_ref(const char *refname, - const unsigned char *sha1, int flags, void *cb_data) +static int add_ref(const char *refname, const struct object_id *oid, + int flags, void *cb_data) { struct commit_array *ca = cb_data; ALLOC_GROW(ca-commits, ca-nr + 1, ca-alloc); - ca-commits[ca-nr] = lookup_commit_reference_gently(sha1, 1); + ca-commits[ca-nr] = lookup_commit_reference_gently(oid-hash, 1); if (ca-commits[ca-nr]) ca-nr++; return 0; @@ -620,8 +617,6 @@ static void post_assign_shallow(struct shallow_info *info, int dst, i, j; int bitmap_nr = (info-ref-nr + 31) / 32; struct commit_array ca; - struct each_ref_fn_sha1_adapter wrapped_add_ref = - {add_ref, ca}; trace_printf_key(trace_shallow, shallow: post_assign_shallow\n); if (ref_status) @@ -645,8 +640,8 @@ static void post_assign_shallow(struct shallow_info *info, info-nr_theirs = dst; memset(ca, 0, sizeof(ca)); - head_ref(each_ref_fn_adapter, wrapped_add_ref); - for_each_ref(each_ref_fn_adapter, wrapped_add_ref); + head_ref(add_ref, ca); + for_each_ref(add_ref, ca); /* Remove unreachable shallow commits from ours */ for (i = dst = 0; i info-nr_ours; i++) { @@ -678,12 +673,10 @@ int delayed_reachability_test(struct shallow_info *si, int c) if (!si-commits) { struct commit_array ca; - struct each_ref_fn_sha1_adapter wrapped_add_ref = - {add_ref, ca}; memset(ca, 0, sizeof(ca)); - head_ref(each_ref_fn_adapter, wrapped_add_ref); - for_each_ref(each_ref_fn_adapter, wrapped_add_ref); + head_ref(add_ref, ca); + for_each_ref(add_ref, ca); si-commits = ca.commits; si-nr_commits = ca.nr; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 13/56] show_ref_cb(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/receive-pack.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index 12ecacd..94d0571 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -197,7 +197,7 @@ static void show_ref(const char *path, const unsigned char *sha1) } } -static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *unused) +static int show_ref_cb(const char *path, const struct object_id *oid, int flag, void *unused) { path = strip_namespace(path); /* @@ -210,7 +210,7 @@ static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, vo */ if (!path) path = .have; - show_ref(path, sha1); + show_ref(path, oid-hash); return 0; } @@ -228,13 +228,11 @@ static void collect_one_alternate_ref(const struct ref *ref, void *data) static void write_head_info(void) { struct sha1_array sa = SHA1_ARRAY_INIT; - struct each_ref_fn_sha1_adapter wrapped_show_ref_cb = - {show_ref_cb, NULL}; for_each_alternate_ref(collect_one_alternate_ref, sa); sha1_array_for_each_unique(sa, show_one_alternate_sha1, NULL); sha1_array_clear(sa); - for_each_ref(each_ref_fn_adapter, wrapped_show_ref_cb); + for_each_ref(show_ref_cb, NULL); if (!sent_capabilities) show_ref(capabilities^{}, null_sha1); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 29/56] http-backend: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- http-backend.c | 23 +-- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/http-backend.c b/http-backend.c index e4f3de3..a2d388d 100644 --- a/http-backend.c +++ b/http-backend.c @@ -350,16 +350,16 @@ static void run_service(const char **argv) exit(1); } -static int show_text_ref(const char *name, const unsigned char *sha1, - int flag, void *cb_data) +static int show_text_ref(const char *name, const struct object_id *oid, +int flag, void *cb_data) { const char *name_nons = strip_namespace(name); struct strbuf *buf = cb_data; - struct object *o = parse_object(sha1); + struct object *o = parse_object(oid-hash); if (!o) return 0; - strbuf_addf(buf, %s\t%s\n, sha1_to_hex(sha1), name_nons); + strbuf_addf(buf, %s\t%s\n, oid_to_hex(oid), name_nons); if (o-type == OBJ_TAG) { o = deref_tag(o, name, 0); if (!o) @@ -395,18 +395,15 @@ static void get_info_refs(char *arg) run_service(argv); } else { - struct each_ref_fn_sha1_adapter wrapped_show_text_ref = - {show_text_ref, buf}; - select_getanyfile(); - for_each_namespaced_ref(each_ref_fn_adapter, wrapped_show_text_ref); + for_each_namespaced_ref(show_text_ref, buf); send_strbuf(text/plain, buf); } strbuf_release(buf); } -static int show_head_ref(const char *refname, const unsigned char *sha1, - int flag, void *cb_data) +static int show_head_ref(const char *refname, const struct object_id *oid, +int flag, void *cb_data) { struct strbuf *buf = cb_data; @@ -419,7 +416,7 @@ static int show_head_ref(const char *refname, const unsigned char *sha1, strbuf_addf(buf, ref: %s\n, target_nons); } else { - strbuf_addf(buf, %s\n, sha1_to_hex(sha1)); + strbuf_addf(buf, %s\n, oid_to_hex(oid)); } return 0; @@ -428,11 +425,9 @@ static int show_head_ref(const char *refname, const unsigned char *sha1, static void get_head(char *arg) { struct strbuf buf = STRBUF_INIT; - struct each_ref_fn_sha1_adapter wrapped_show_head_ref = - {show_head_ref, buf}; select_getanyfile(); - head_ref_namespaced(each_ref_fn_adapter, wrapped_show_head_ref); + head_ref_namespaced(show_head_ref, buf); send_strbuf(text/plain, buf); strbuf_release(buf); } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 10/56] grab_single_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/for-each-ref.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index caccd93..05ce28c 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -840,7 +840,8 @@ struct grab_ref_cbdata { * A call-back given to for_each_ref(). Filter refs and keep them for * later object processing. */ -static int grab_single_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int grab_single_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { struct grab_ref_cbdata *cb = cb_data; struct refinfo *ref; @@ -878,7 +879,7 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f */ ref = xcalloc(1, sizeof(*ref)); ref-refname = xstrdup(refname); - hashcpy(ref-objectname, sha1); + hashcpy(ref-objectname, oid-hash); ref-flag = flag; cnt = cb-grab_cnt; @@ -1072,8 +1073,6 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) int maxcount = 0, quote_style = 0; struct refinfo **refs; struct grab_ref_cbdata cbdata; - struct each_ref_fn_sha1_adapter wrapped_grab_single_ref = - {grab_single_ref, cbdata}; struct option opts[] = { OPT_BIT('s', shell, quote_style, @@ -1113,7 +1112,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) memset(cbdata, 0, sizeof(cbdata)); cbdata.grab_pattern = argv; - for_each_rawref(each_ref_fn_adapter, wrapped_grab_single_ref); + for_each_rawref(grab_single_ref, cbdata); refs = cbdata.grab_array; num_refs = cbdata.grab_cnt; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 26/56] show_ref(): convert local variable peeled to object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-ref.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/show-ref.c b/builtin/show-ref.c index 18f84fb..dfbc314 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -30,7 +30,7 @@ static int show_ref(const char *refname, const struct object_id *oid, int flag, void *cbdata) { const char *hex; - unsigned char peeled[20]; + struct object_id peeled; if (show_head !strcmp(refname, HEAD)) goto match; @@ -82,8 +82,8 @@ match: if (!deref_tags) return 0; - if (!peel_ref(refname, peeled)) { - hex = find_unique_abbrev(peeled, abbrev); + if (!peel_ref(refname, peeled.hash)) { + hex = find_unique_abbrev(peeled.hash, abbrev); printf(%s %s^{}\n, hex, refname); } return 0; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 06/56] append_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/branch.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/branch.c b/builtin/branch.c index b27adcb..0d3b9af 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -328,7 +328,7 @@ static int match_patterns(const char **pattern, const char *refname) return 0; } -static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data) +static int append_ref(const char *refname, const struct object_id *oid, int flags, void *cb_data) { struct append_ref_cb *cb = (struct append_ref_cb *)(cb_data); struct ref_list *ref_list = cb-ref_list; @@ -365,7 +365,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags, commit = NULL; if (ref_list-verbose || ref_list-with_commit || merge_filter != NO_FILTER) { - commit = lookup_commit_reference_gently(sha1, 1); + commit = lookup_commit_reference_gently(oid-hash, 1); if (!commit) { cb-ret = error(_(branch '%s' does not point at a commit), refname); return 0; @@ -631,8 +631,6 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru int i; struct append_ref_cb cb; struct ref_list ref_list; - struct each_ref_fn_sha1_adapter wrapped_append_ref = - {append_ref, cb}; memset(ref_list, 0, sizeof(ref_list)); ref_list.kinds = kinds; @@ -644,7 +642,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru cb.ref_list = ref_list; cb.pattern = pattern; cb.ret = 0; - for_each_rawref(each_ref_fn_adapter, wrapped_append_ref); + for_each_rawref(append_ref, cb); if (merge_filter != NO_FILTER) { struct commit *filter; filter = lookup_commit_reference_gently(merge_filter_ref, 0); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 20/56] builtin/show-branch: rewrite functions to take object_id arguments
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-branch.c | 35 +-- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index b06f966..7e00657 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -394,39 +394,42 @@ static int append_ref(const char *refname, const unsigned char *sha1, return 0; } -static int append_head_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int append_head_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { - unsigned char tmp[20]; + struct object_id tmp; int ofs = 11; if (!starts_with(refname, refs/heads/)) return 0; /* If both heads/foo and tags/foo exists, get_sha1 would * get confused. */ - if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1)) + if (get_sha1(refname + ofs, tmp.hash) || oidcmp(tmp, oid)) ofs = 5; - return append_ref(refname + ofs, sha1, 0); + return append_ref(refname + ofs, oid-hash, 0); } -static int append_remote_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int append_remote_ref(const char *refname, const struct object_id *oid, +int flag, void *cb_data) { - unsigned char tmp[20]; + struct object_id tmp; int ofs = 13; if (!starts_with(refname, refs/remotes/)) return 0; /* If both heads/foo and tags/foo exists, get_sha1 would * get confused. */ - if (get_sha1(refname + ofs, tmp) || hashcmp(tmp, sha1)) + if (get_sha1(refname + ofs, tmp.hash) || oidcmp(tmp, oid)) ofs = 5; - return append_ref(refname + ofs, sha1, 0); + return append_ref(refname + ofs, oid-hash, 0); } -static int append_tag_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int append_tag_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { if (!starts_with(refname, refs/tags/)) return 0; - return append_ref(refname + 5, sha1, 0); + return append_ref(refname + 5, oid-hash, 0); } static const char *match_ref_pattern = NULL; @@ -457,9 +460,9 @@ static int append_matching_ref(const char *refname, const struct object_id *oid, if (wildmatch(match_ref_pattern, tail, 0, NULL)) return 0; if (starts_with(refname, refs/heads/)) - return append_head_ref(refname, oid-hash, flag, cb_data); + return append_head_ref(refname, oid, flag, cb_data); if (starts_with(refname, refs/tags/)) - return append_tag_ref(refname, oid-hash, flag, cb_data); + return append_tag_ref(refname, oid, flag, cb_data); return append_ref(refname, oid-hash, 0); } @@ -467,18 +470,14 @@ static void snarf_refs(int head, int remotes) { if (head) { int orig_cnt = ref_name_cnt; - struct each_ref_fn_sha1_adapter wrapped_append_head_ref = - {append_head_ref, NULL}; - for_each_ref(each_ref_fn_adapter, wrapped_append_head_ref); + for_each_ref(append_head_ref, NULL); sort_ref_range(orig_cnt, ref_name_cnt); } if (remotes) { int orig_cnt = ref_name_cnt; - struct each_ref_fn_sha1_adapter wrapped_append_remote_ref = - {append_remote_ref, NULL}; - for_each_ref(each_ref_fn_adapter, wrapped_append_remote_ref); + for_each_ref(append_remote_ref, NULL); sort_ref_range(orig_cnt, ref_name_cnt); } } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 1/2] for-each-ref: re-structure code for moving to 'ref-filter'
Karthik Nayak karthik@gmail.com writes: I do not see much point in renaming between these two. The latter makes it sound as if this is only for filtering and from that angle of view is probably a worse name. If you do not think of a better one, and if you are going to name the array that contains this thing ref_list, calling ref_list_item would be following suit to what string-list did. Well I just wanted to keep it related to 'ref-filter', I think 'ref_list_item' sounds better after seeing your point of view. Also I think Matthieu already commented that filter was out of place for that struct. I still think your ref_list is better called ref_array, but that is a minor point. Use of foo_list in our codebase is predominantly (because we use commit_list very often in the core part of the system) for a linear linked list where you do not have a random access to the items. string-list is misnomer, I would think. I didn't know about the we are trying to move away from calling the name of objects as sha1[]. Will leave it as objectname then. I think you now know after seeing that 56-patch series ;-) You didn't explain why you reordered the fields, either. Were you planning to make the name[] field to flex-array to reduce need for one level of redirection or something? Yes! exactly why the re-order, was going to rebase it and squash it in, if the code seemed to be up and running. If that is the case, I would suggest making that turn it flex array a separate step. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 00/56] Convert parts of refs.c to struct object_id
On Mon, May 25, 2015 at 12:34:59PM -0700, Junio C Hamano wrote: [PATCH 01/56] was authored by you but has Michael's sign-off, which looked somewhat odd to me, though. Yes, it does. He picked it up from me, and signed off, and I took his branch. I don't believe he changed it, but I didn't check for certain. So technically, although I wrote it, I also received it from him without changing it, so both (a) and (c) of the DCO apply. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187 signature.asc Description: Digital signature
Re: [PATCH v11 2/5] command-list.txt: add the common groups block
On 05/21/2015 08:01 PM, Eric Sunshine wrote: On Thu, May 21, 2015 at 1:39 PM, Sébastien Guimmara sebastien.guimm...@gmail.com wrote: The ultimate goal is for git help to display common commands in groups rather than alphabetically. As a first step, define the groups in a new block, and then assign a group to each common command. Helped-by: Eric Sunshine sunsh...@sunshineco.com Helped-by: Junio C Hamano gits...@pobox.com Helped-by: Emma Jane Hogbin Westby emma.wes...@gmail.com Signed-off-by: Sébastien Guimmara sebastien.guimm...@gmail.com --- diff --git a/command-list.txt b/command-list.txt index 181a9c2..32ddab3 100644 --- a/command-list.txt +++ b/command-list.txt @@ -1,3 +1,14 @@ +# common commands are grouped by themes +# these groups are output by 'git help' in the order declared here. +# map each common command in the command list to one of these groups. +### common groups (do not change this line) +init start a working area (see also: git help tutorial) +worktree work on the current change (see also: git help everyday) +info examine the history and state (see also: git help revisions) +history grow, mark and tweak your common history +remote collaborate (see also: git help workflows) + +# List of known git commands. This is odd. The above line was removed in 1/5 but then re-appears here in 2/5. I think the intent is that it should remain removed. ### command list (do not change this line) # command name category [deprecated] [common] git-add mainporcelain common My mistake. This will be corrected in the next version. Thank you for taking time to review this series. Sébastien -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 09/56] builtin/fetch: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/fetch.c | 23 +++ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/builtin/fetch.c b/builtin/fetch.c index 4878c3d..8d5b2db 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -179,13 +179,15 @@ static void add_merge_config(struct ref **head, } } -static int add_existing(const char *refname, const unsigned char *sha1, +static int add_existing(const char *refname, const struct object_id *oid, int flag, void *cbdata) { struct string_list *list = (struct string_list *)cbdata; struct string_list_item *item = string_list_insert(list, refname); - item-util = xmalloc(20); - hashcpy(item-util, sha1); + struct object_id *old_oid = xmalloc(sizeof(*old_oid)); + + oidcpy(old_oid, oid); + item-util = old_oid; return 0; } @@ -208,10 +210,8 @@ static void find_non_local_tags(struct transport *transport, struct string_list remote_refs = STRING_LIST_INIT_NODUP; const struct ref *ref; struct string_list_item *item = NULL; - struct each_ref_fn_sha1_adapter wrapped_add_existing = - {add_existing, existing_refs}; - for_each_ref(each_ref_fn_adapter, wrapped_add_existing); + for_each_ref(add_existing, existing_refs); for (ref = transport_get_remote_refs(transport); ref; ref = ref-next) { if (!starts_with(ref-name, refs/tags/)) continue; @@ -886,10 +886,8 @@ static int do_fetch(struct transport *transport, struct ref *rm; int autotags = (transport-remote-fetch_tags == 1); int retcode = 0; - struct each_ref_fn_sha1_adapter wrapped_add_existing = - {add_existing, existing_refs}; - for_each_ref(each_ref_fn_adapter, wrapped_add_existing); + for_each_ref(add_existing, existing_refs); if (tags == TAGS_DEFAULT) { if (transport-remote-fetch_tags == 2) @@ -917,9 +915,10 @@ static int do_fetch(struct transport *transport, struct string_list_item *peer_item = string_list_lookup(existing_refs, rm-peer_ref-name); - if (peer_item) - hashcpy(rm-peer_ref-old_sha1, - peer_item-util); + if (peer_item) { + struct object_id *old_oid = peer_item-util; + hashcpy(rm-peer_ref-old_sha1, old_oid-hash); + } } } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 16/56] add_branch_for_removal(): don't set util field of string_list entries
From: Michael Haggerty mhag...@alum.mit.edu They were never used. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/remote.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 1986e98..ab39fea 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -513,7 +513,6 @@ static int add_branch_for_removal(const char *refname, { struct branches_for_remote *branches = cb_data; struct refspec refspec; - struct string_list_item *item; struct known_remote *kr; memset(refspec, 0, sizeof(refspec)); @@ -543,9 +542,7 @@ static int add_branch_for_removal(const char *refname, if (flags REF_ISSYMREF) return unlink(git_path(%s, refname)); - item = string_list_append(branches-branches, refname); - item-util = xmalloc(20); - hashcpy(item-util, oid-hash); + string_list_append(branches-branches, refname); return 0; } @@ -828,7 +825,7 @@ static int rm(int argc, const char **argv) if (!result) result = remove_branches(branches); - string_list_clear(branches, 1); + string_list_clear(branches, 0); if (skipped.nr) { fprintf_ln(stderr, -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 02/56] each_ref_fn: change to take an object_id parameter
From: Michael Haggerty mhag...@alum.mit.edu Change typedef each_ref_fn to take a const struct object_id *oid parameter instead of const unsigned char *sha1. To aid this transition, implement an adapter that can be used to wrap old-style functions matching the old typedef, which is now called each_ref_sha1_fn), and make such functions callable via the new interface. This requires the old function and its cb_data to be wrapped in a struct each_ref_fn_sha1_adapter, and that object to be used as the cb_data for an adapter function, each_ref_fn_adapter(). This is an enormous diff, but most of it consists of simple, mechanical changes to the sites that call any of the for_each_ref family of functions. Subsequent to this change, the call sites can be rewritten one by one to use the new interface. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- Documentation/technical/api-ref-iteration.txt | 2 +- bisect.c | 5 +++- builtin/branch.c | 4 ++- builtin/checkout.c| 4 ++- builtin/describe.c| 4 ++- builtin/fetch.c | 8 +++-- builtin/for-each-ref.c| 4 ++- builtin/fsck.c| 9 -- builtin/name-rev.c| 4 ++- builtin/pack-objects.c| 12 ++-- builtin/receive-pack.c| 5 +++- builtin/reflog.c | 9 -- builtin/remote.c | 13 +++-- builtin/replace.c | 4 ++- builtin/rev-parse.c | 33 - builtin/show-branch.c | 15 -- builtin/show-ref.c| 11 +-- builtin/tag.c | 4 ++- fetch-pack.c | 17 --- help.c| 4 ++- http-backend.c| 9 -- log-tree.c| 7 +++-- notes.c | 5 +++- reachable.c | 6 ++-- refs.c| 42 +-- refs.h| 13 - remote.c | 10 +-- replace_object.c | 4 ++- revision.c| 33 + server-info.c | 5 +++- sha1_name.c | 5 +++- shallow.c | 19 submodule.c | 15 -- transport.c | 5 +++- upload-pack.c | 18 walker.c | 5 +++- 36 files changed, 275 insertions(+), 97 deletions(-) diff --git a/Documentation/technical/api-ref-iteration.txt b/Documentation/technical/api-ref-iteration.txt index 02adfd4..37379d8 100644 --- a/Documentation/technical/api-ref-iteration.txt +++ b/Documentation/technical/api-ref-iteration.txt @@ -6,7 +6,7 @@ Iteration of refs is done by using an iterate function which will call a callback function for every ref. The callback function has this signature: - int handle_one_ref(const char *refname, const unsigned char *sha1, + int handle_one_ref(const char *refname, const struct object_id *oid, int flags, void *cb_data); There are different kinds of iterate functions which all take a diff --git a/bisect.c b/bisect.c index 10f5e57..0848d91 100644 --- a/bisect.c +++ b/bisect.c @@ -417,7 +417,10 @@ static int register_ref(const char *refname, const unsigned char *sha1, static int read_bisect_refs(void) { - return for_each_ref_in(refs/bisect/, register_ref, NULL); + struct each_ref_fn_sha1_adapter wrapped_register_ref = + {register_ref, NULL}; + + return for_each_ref_in(refs/bisect/, each_ref_fn_adapter, wrapped_register_ref); } static void read_bisect_paths(struct argv_array *array) diff --git a/builtin/branch.c b/builtin/branch.c index 9cbab18..b27adcb 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -631,6 +631,8 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru int i; struct append_ref_cb cb; struct ref_list ref_list; + struct each_ref_fn_sha1_adapter wrapped_append_ref = + {append_ref, cb}; memset(ref_list, 0, sizeof(ref_list)); ref_list.kinds = kinds; @@ -642,7 +644,7 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru cb.ref_list = ref_list;
[PATCH v3 19/56] append_matching_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-branch.c | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index cf918f4..b06f966 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -440,7 +440,8 @@ static int count_slash(const char *s) return cnt; } -static int append_matching_ref(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int append_matching_ref(const char *refname, const struct object_id *oid, + int flag, void *cb_data) { /* we want to allow pattern hold/asterisk to show all * branches under refs/heads/hold/, and v0.99.9? to show @@ -456,10 +457,10 @@ static int append_matching_ref(const char *refname, const unsigned char *sha1, i if (wildmatch(match_ref_pattern, tail, 0, NULL)) return 0; if (starts_with(refname, refs/heads/)) - return append_head_ref(refname, sha1, flag, cb_data); + return append_head_ref(refname, oid-hash, flag, cb_data); if (starts_with(refname, refs/tags/)) - return append_tag_ref(refname, sha1, flag, cb_data); - return append_ref(refname, sha1, 0); + return append_tag_ref(refname, oid-hash, flag, cb_data); + return append_ref(refname, oid-hash, 0); } static void snarf_refs(int head, int remotes) @@ -544,12 +545,10 @@ static void append_one_rev(const char *av) if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) { /* glob style match */ int saved_matches = ref_name_cnt; - struct each_ref_fn_sha1_adapter wrapped_append_matching_ref = - {append_matching_ref, NULL}; match_ref_pattern = av; match_ref_slash = count_slash(av); - for_each_ref(each_ref_fn_adapter, wrapped_append_matching_ref); + for_each_ref(append_matching_ref, NULL); if (saved_matches == ref_name_cnt ref_name_cnt MAX_REVS) error(no matching refs with %s, av); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 04/56] handle_one_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- revision.c | 35 +-- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/revision.c b/revision.c index 93b23a6..cfe3876 100644 --- a/revision.c +++ b/revision.c @@ -1218,7 +1218,8 @@ int ref_excluded(struct string_list *ref_excludes, const char *path) return 0; } -static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int handle_one_ref(const char *path, const struct object_id *oid, + int flag, void *cb_data) { struct all_refs_cb *cb = cb_data; struct object *object; @@ -1226,9 +1227,9 @@ static int handle_one_ref(const char *path, const unsigned char *sha1, int flag, if (ref_excluded(cb-all_revs-ref_excludes, path)) return 0; - object = get_reference(cb-all_revs, path, sha1, cb-all_flags); + object = get_reference(cb-all_revs, path, oid-hash, cb-all_flags); add_rev_cmdline(cb-all_revs, object, path, REV_CMD_REF, cb-all_flags); - add_pending_sha1(cb-all_revs, path, sha1, cb-all_flags); + add_pending_sha1(cb-all_revs, path, oid-hash, cb-all_flags); return 0; } @@ -1261,11 +1262,8 @@ static void handle_refs(const char *submodule, struct rev_info *revs, unsigned f int (*for_each)(const char *, each_ref_fn, void *)) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, cb}; - init_all_refs_cb(cb, revs, flags); - for_each(submodule, each_ref_fn_adapter, wrapped_handle_one_ref); + for_each(submodule, handle_one_ref, cb); } static void handle_one_reflog_commit(unsigned char *sha1, void *cb_data) @@ -2126,11 +2124,8 @@ static int handle_revision_pseudo_opt(const char *submodule, clear_ref_exclusion(revs-ref_excludes); } else if ((argcount = parse_long_opt(glob, argv, optarg))) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, cb}; - init_all_refs_cb(cb, revs, *flags); - for_each_glob_ref(each_ref_fn_adapter, optarg, wrapped_handle_one_ref); + for_each_glob_ref(handle_one_ref, optarg, cb); clear_ref_exclusion(revs-ref_excludes); return argcount; } else if ((argcount = parse_long_opt(exclude, argv, optarg))) { @@ -2138,30 +2133,18 @@ static int handle_revision_pseudo_opt(const char *submodule, return argcount; } else if (starts_with(arg, --branches=)) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, cb}; - init_all_refs_cb(cb, revs, *flags); - for_each_glob_ref_in(each_ref_fn_adapter, arg + 11, refs/heads/, -wrapped_handle_one_ref); + for_each_glob_ref_in(handle_one_ref, arg + 11, refs/heads/, cb); clear_ref_exclusion(revs-ref_excludes); } else if (starts_with(arg, --tags=)) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, cb}; - init_all_refs_cb(cb, revs, *flags); - for_each_glob_ref_in(each_ref_fn_adapter, arg + 7, refs/tags/, -wrapped_handle_one_ref); + for_each_glob_ref_in(handle_one_ref, arg + 7, refs/tags/, cb); clear_ref_exclusion(revs-ref_excludes); } else if (starts_with(arg, --remotes=)) { struct all_refs_cb cb; - struct each_ref_fn_sha1_adapter wrapped_handle_one_ref = - {handle_one_ref, cb}; - init_all_refs_cb(cb, revs, *flags); - for_each_glob_ref_in(each_ref_fn_adapter, arg + 10, refs/remotes/, -wrapped_handle_one_ref); + for_each_glob_ref_in(handle_one_ref, arg + 10, refs/remotes/, cb); clear_ref_exclusion(revs-ref_excludes); } else if (!strcmp(arg, --reflog)) { add_reflogs_to_pending(revs, *flags); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 08/56] get_name(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Rewrite to take an object_id argument and convert the local variable peeled object_id. Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/describe.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/builtin/describe.c b/builtin/describe.c index 7d0c855..a36c829 100644 --- a/builtin/describe.c +++ b/builtin/describe.c @@ -119,10 +119,10 @@ static void add_to_known_names(const char *path, } } -static int get_name(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int get_name(const char *path, const struct object_id *oid, int flag, void *cb_data) { int is_tag = starts_with(path, refs/tags/); - unsigned char peeled[20]; + struct object_id peeled; int is_annotated, prio; /* Reject anything outside refs/tags/ unless --all */ @@ -134,10 +134,10 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void return 0; /* Is it annotated? */ - if (!peel_ref(path, peeled)) { - is_annotated = !!hashcmp(sha1, peeled); + if (!peel_ref(path, peeled.hash)) { + is_annotated = !!oidcmp(oid, peeled); } else { - hashcpy(peeled, sha1); + oidcpy(peeled, oid); is_annotated = 0; } @@ -154,7 +154,7 @@ static int get_name(const char *path, const unsigned char *sha1, int flag, void else prio = 0; - add_to_known_names(all ? path + 5 : path + 10, peeled, prio, sha1); + add_to_known_names(all ? path + 5 : path + 10, peeled.hash, prio, oid-hash); return 0; } @@ -413,8 +413,6 @@ int cmd_describe(int argc, const char **argv, const char *prefix) PARSE_OPT_OPTARG, NULL, (intptr_t) -dirty}, OPT_END(), }; - struct each_ref_fn_sha1_adapter wrapped_get_name = - {get_name, NULL}; git_config(git_default_config, NULL); argc = parse_options(argc, argv, prefix, options, describe_usage, 0); @@ -453,7 +451,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix) } hashmap_init(names, (hashmap_cmp_fn) commit_name_cmp, 0); - for_each_rawref(each_ref_fn_adapter, wrapped_get_name); + for_each_rawref(get_name, NULL); if (!names.size !always) die(_(No names found, cannot describe anything.)); -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 33/56] string_list_add_one_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- notes.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/notes.c b/notes.c index baa1c41..df08209 100644 --- a/notes.c +++ b/notes.c @@ -918,7 +918,7 @@ out: return ret; } -static int string_list_add_one_ref(const char *refname, const unsigned char *sha1, +static int string_list_add_one_ref(const char *refname, const struct object_id *oid, int flag, void *cb) { struct string_list *refs = cb; @@ -932,12 +932,9 @@ static int string_list_add_one_ref(const char *refname, const unsigned char *sha */ void string_list_add_refs_by_glob(struct string_list *list, const char *glob) { - struct each_ref_fn_sha1_adapter wrapped_string_list_add_one_ref = - {string_list_add_one_ref, list}; - assert(list-strdup_strings); if (has_glob_specials(glob)) { - for_each_glob_ref(each_ref_fn_adapter, glob, wrapped_string_list_add_one_ref); + for_each_glob_ref(string_list_add_one_ref, glob, list); } else { unsigned char sha1[20]; if (get_sha1(glob, sha1)) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 03/56] builtin/rev-parse: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/rev-parse.c | 41 + 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index e75ce75..b623239 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -190,17 +190,17 @@ static int show_default(void) return 0; } -static int show_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data) { if (ref_excluded(ref_excludes, refname)) return 0; - show_rev(NORMAL, sha1, refname); + show_rev(NORMAL, oid-hash, refname); return 0; } -static int anti_reference(const char *refname, const unsigned char *sha1, int flag, void *cb_data) +static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data) { - show_rev(REVERSED, sha1, refname); + show_rev(REVERSED, oid-hash, refname); return 0; } @@ -511,10 +511,6 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) unsigned int flags = 0; const char *name = NULL; struct object_context unused; - struct each_ref_fn_sha1_adapter wrapped_show_reference = - {show_reference, NULL}; - struct each_ref_fn_sha1_adapter wrapped_anti_reference = - {anti_reference, NULL}; if (argc 1 !strcmp(--parseopt, argv[1])) return cmd_parseopt(argc - 1, argv + 1, prefix); @@ -656,7 +652,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, --all)) { - for_each_ref(each_ref_fn_adapter, wrapped_show_reference); + for_each_ref(show_reference, NULL); continue; } if (starts_with(arg, --disambiguate=)) { @@ -664,48 +660,45 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, --bisect)) { - for_each_ref_in(refs/bisect/bad, - each_ref_fn_adapter, wrapped_show_reference); - for_each_ref_in(refs/bisect/good, - each_ref_fn_adapter, wrapped_anti_reference); + for_each_ref_in(refs/bisect/bad, show_reference, NULL); + for_each_ref_in(refs/bisect/good, anti_reference, NULL); continue; } if (starts_with(arg, --branches=)) { - for_each_glob_ref_in(each_ref_fn_adapter, arg + 11, - refs/heads/, wrapped_show_reference); + for_each_glob_ref_in(show_reference, arg + 11, + refs/heads/, NULL); clear_ref_exclusion(ref_excludes); continue; } if (!strcmp(arg, --branches)) { - for_each_branch_ref(each_ref_fn_adapter, wrapped_show_reference); + for_each_branch_ref(show_reference, NULL); clear_ref_exclusion(ref_excludes); continue; } if (starts_with(arg, --tags=)) { - for_each_glob_ref_in(each_ref_fn_adapter, arg + 7, - refs/tags/, wrapped_show_reference); + for_each_glob_ref_in(show_reference, arg + 7, + refs/tags/, NULL); clear_ref_exclusion(ref_excludes); continue; } if (!strcmp(arg, --tags)) { - for_each_tag_ref(each_ref_fn_adapter, wrapped_show_reference); + for_each_tag_ref(show_reference, NULL); clear_ref_exclusion(ref_excludes); continue; } if (starts_with(arg, --glob=)) { - for_each_glob_ref(each_ref_fn_adapter, arg + 7, - wrapped_show_reference); + for_each_glob_ref(show_reference, arg +
[PATCH v3 21/56] append_one_rev(): rewrite to work with object_id
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/show-branch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 7e00657..b861e41 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -536,9 +536,9 @@ static int show_independent(struct commit **rev, static void append_one_rev(const char *av) { - unsigned char revkey[20]; - if (!get_sha1(av, revkey)) { - append_ref(av, revkey, 0); + struct object_id revkey; + if (!get_sha1(av, revkey.hash)) { + append_ref(av, revkey.hash, 0); return; } if (strchr(av, '*') || strchr(av, '?') || strchr(av, '[')) { -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 07/56] add_pending_uninteresting_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/checkout.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 9416aa2..9b49f0e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -702,10 +702,10 @@ static void update_refs_for_switch(const struct checkout_opts *opts, } static int add_pending_uninteresting_ref(const char *refname, -const unsigned char *sha1, +const struct object_id *oid, int flags, void *cb_data) { - add_pending_sha1(cb_data, refname, sha1, UNINTERESTING); + add_pending_sha1(cb_data, refname, oid-hash, UNINTERESTING); return 0; } @@ -784,8 +784,6 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) struct rev_info revs; struct object *object = old-object; struct object_array refs; - struct each_ref_fn_sha1_adapter wrapped_add_pending_uninteresting_ref = - {add_pending_uninteresting_ref, revs}; init_revisions(revs, NULL); setup_revisions(0, NULL, revs, NULL); @@ -793,7 +791,7 @@ static void orphaned_commit_warning(struct commit *old, struct commit *new) object-flags = ~UNINTERESTING; add_pending_object(revs, object, sha1_to_hex(object-sha1)); - for_each_ref(each_ref_fn_adapter, wrapped_add_pending_uninteresting_ref); + for_each_ref(add_pending_uninteresting_ref, revs); add_pending_sha1(revs, HEAD, new-object.sha1, UNINTERESTING); refs = revs.pending; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 15/56] add_branch_for_removal(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/remote.c | 8 +++- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/builtin/remote.c b/builtin/remote.c index 27a611b..1986e98 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -509,7 +509,7 @@ struct branches_for_remote { }; static int add_branch_for_removal(const char *refname, - const unsigned char *sha1, int flags, void *cb_data) + const struct object_id *oid, int flags, void *cb_data) { struct branches_for_remote *branches = cb_data; struct refspec refspec; @@ -545,7 +545,7 @@ static int add_branch_for_removal(const char *refname, item = string_list_append(branches-branches, refname); item-util = xmalloc(20); - hashcpy(item-util, sha1); + hashcpy(item-util, oid-hash); return 0; } @@ -783,8 +783,6 @@ static int rm(int argc, const char **argv) struct string_list skipped = STRING_LIST_INIT_DUP; struct branches_for_remote cb_data; int i, result; - struct each_ref_fn_sha1_adapter wrapped_add_branch_for_removal = - {add_branch_for_removal, cb_data}; memset(cb_data, 0, sizeof(cb_data)); cb_data.branches = branches; @@ -825,7 +823,7 @@ static int rm(int argc, const char **argv) * refs, which are invalidated when deleting a branch. */ cb_data.remote = remote; - result = for_each_ref(each_ref_fn_adapter, wrapped_add_branch_for_removal); + result = for_each_ref(add_branch_for_removal, cb_data); strbuf_release(buf); if (!result) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 11/56] name_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/name-rev.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/builtin/name-rev.c b/builtin/name-rev.c index 41bdf0a..248a3eb 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -138,9 +138,9 @@ static int tipcmp(const void *a_, const void *b_) return hashcmp(a-sha1, b-sha1); } -static int name_ref(const char *path, const unsigned char *sha1, int flags, void *cb_data) +static int name_ref(const char *path, const struct object_id *oid, int flags, void *cb_data) { - struct object *o = parse_object(sha1); + struct object *o = parse_object(oid-hash); struct name_ref_data *data = cb_data; int can_abbreviate_output = data-tags_only data-name_only; int deref = 0; @@ -160,7 +160,7 @@ static int name_ref(const char *path, const unsigned char *sha1, int flags, void } } - add_to_tip_table(sha1, path, can_abbreviate_output); + add_to_tip_table(oid-hash, path, can_abbreviate_output); while (o o-type == OBJ_TAG) { struct tag *t = (struct tag *) o; @@ -305,8 +305,6 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) struct object_array revs = OBJECT_ARRAY_INIT; int all = 0, transform_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0; struct name_ref_data data = { 0, 0, NULL }; - struct each_ref_fn_sha1_adapter wrapped_name_ref = - {name_ref, data}; struct option opts[] = { OPT_BOOL(0, name-only, data.name_only, N_(print only names (no SHA-1))), OPT_BOOL(0, tags, data.tags_only, N_(only use tags to name the commits)), @@ -379,7 +377,7 @@ int cmd_name_rev(int argc, const char **argv, const char *prefix) if (cutoff) cutoff = cutoff - CUTOFF_DATE_SLOP; - for_each_ref(each_ref_fn_adapter, wrapped_name_ref); + for_each_ref(name_ref, data); if (transform_stdin) { char buffer[2048]; -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 12/56] builtin/pack-objects: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/pack-objects.c | 26 ++ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 81f0e57..80fe8c7 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -540,11 +540,11 @@ static enum write_one_status write_one(struct sha1file *f, return WRITE_ONE_WRITTEN; } -static int mark_tagged(const char *path, const unsigned char *sha1, int flag, +static int mark_tagged(const char *path, const struct object_id *oid, int flag, void *cb_data) { unsigned char peeled[20]; - struct object_entry *entry = packlist_find(to_pack, sha1, NULL); + struct object_entry *entry = packlist_find(to_pack, oid-hash, NULL); if (entry) entry-tagged = 1; @@ -626,8 +626,6 @@ static struct object_entry **compute_write_order(void) struct object_entry **wo = xmalloc(to_pack.nr_objects * sizeof(*wo)); struct object_entry *objects = to_pack.objects; - struct each_ref_fn_sha1_adapter wrapped_mark_tagged = - {mark_tagged, NULL}; for (i = 0; i to_pack.nr_objects; i++) { objects[i].tagged = 0; @@ -653,7 +651,7 @@ static struct object_entry **compute_write_order(void) /* * Mark objects that are at the tip of tags. */ - for_each_tag_ref(each_ref_fn_adapter, wrapped_mark_tagged); + for_each_tag_ref(mark_tagged, NULL); /* * Give the objects in the original recency order until @@ -2099,14 +2097,14 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size, #define ll_find_deltas(l, s, w, d, p) find_deltas(l, s, w, d, p) #endif -static int add_ref_tag(const char *path, const unsigned char *sha1, int flag, void *cb_data) +static int add_ref_tag(const char *path, const struct object_id *oid, int flag, void *cb_data) { - unsigned char peeled[20]; + struct object_id peeled; if (starts_with(path, refs/tags/) /* is a tag? */ - !peel_ref(path, peeled) /* peelable? */ - packlist_find(to_pack, peeled, NULL)) /* object packed? */ - add_object_entry(sha1, OBJ_TAG, NULL, 0); + !peel_ref(path, peeled.hash) /* peelable? */ + packlist_find(to_pack, peeled.hash, NULL)) /* object packed? */ + add_object_entry(oid-hash, OBJ_TAG, NULL, 0); return 0; } @@ -2786,12 +2784,8 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix) argv_array_clear(rp); } cleanup_preferred_base(); - if (include_tag nr_result) { - struct each_ref_fn_sha1_adapter wrapped_add_ref_tag = - {add_ref_tag, NULL}; - - for_each_ref(each_ref_fn_adapter, wrapped_add_ref_tag); - } + if (include_tag nr_result) + for_each_ref(add_ref_tag, NULL); stop_progress(progress_state); if (non_empty !nr_result) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 18/56] show_reference(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/replace.c | 18 -- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/builtin/replace.c b/builtin/replace.c index bcf1508..0d52e7f 100644 --- a/builtin/replace.c +++ b/builtin/replace.c @@ -35,7 +35,7 @@ struct show_data { enum replace_format format; }; -static int show_reference(const char *refname, const unsigned char *sha1, +static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data) { struct show_data *data = cb_data; @@ -44,19 +44,19 @@ static int show_reference(const char *refname, const unsigned char *sha1, if (data-format == REPLACE_FORMAT_SHORT) printf(%s\n, refname); else if (data-format == REPLACE_FORMAT_MEDIUM) - printf(%s - %s\n, refname, sha1_to_hex(sha1)); + printf(%s - %s\n, refname, oid_to_hex(oid)); else { /* data-format == REPLACE_FORMAT_LONG */ - unsigned char object[20]; + struct object_id object; enum object_type obj_type, repl_type; - if (get_sha1(refname, object)) + if (get_sha1(refname, object.hash)) return error(Failed to resolve '%s' as a valid ref., refname); - obj_type = sha1_object_info(object, NULL); - repl_type = sha1_object_info(sha1, NULL); + obj_type = sha1_object_info(object.hash, NULL); + repl_type = sha1_object_info(oid-hash, NULL); printf(%s (%s) - %s (%s)\n, refname, typename(obj_type), - sha1_to_hex(sha1), typename(repl_type)); + oid_to_hex(oid), typename(repl_type)); } } @@ -66,8 +66,6 @@ static int show_reference(const char *refname, const unsigned char *sha1, static int list_replace_refs(const char *pattern, const char *format) { struct show_data data; - struct each_ref_fn_sha1_adapter wrapped_show_reference = - {show_reference, (void *) data}; if (pattern == NULL) pattern = *; @@ -84,7 +82,7 @@ static int list_replace_refs(const char *pattern, const char *format) valid formats are 'short', 'medium' and 'long'\n, format); - for_each_replace_ref(each_ref_fn_adapter, wrapped_show_reference); + for_each_replace_ref(show_reference, (void *)data); return 0; } -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 27/56] builtin/show-ref: rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- builtin/tag.c | 20 +--- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/builtin/tag.c b/builtin/tag.c index 7d8cd8c..5f6cdc5 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -176,7 +176,7 @@ static enum contains_result contains(struct commit *candidate, return contains_test(candidate, want); } -static void show_tag_lines(const unsigned char *sha1, int lines) +static void show_tag_lines(const struct object_id *oid, int lines) { int i; unsigned long size; @@ -184,14 +184,14 @@ static void show_tag_lines(const unsigned char *sha1, int lines) char *buf, *sp, *eol; size_t len; - buf = read_sha1_file(sha1, type, size); + buf = read_sha1_file(oid-hash, type, size); if (!buf) - die_errno(unable to read object %s, sha1_to_hex(sha1)); + die_errno(unable to read object %s, oid_to_hex(oid)); if (type != OBJ_COMMIT type != OBJ_TAG) goto free_return; if (!size) die(an empty %s object %s?, - typename(type), sha1_to_hex(sha1)); + typename(type), oid_to_hex(oid)); /* skip header */ sp = strstr(buf, \n\n); @@ -215,7 +215,7 @@ free_return: free(buf); } -static int show_reference(const char *refname, const unsigned char *sha1, +static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data) { struct tag_filter *filter = cb_data; @@ -224,14 +224,14 @@ static int show_reference(const char *refname, const unsigned char *sha1, if (filter-with_commit) { struct commit *commit; - commit = lookup_commit_reference_gently(sha1, 1); + commit = lookup_commit_reference_gently(oid-hash, 1); if (!commit) return 0; if (!contains(commit, filter-with_commit)) return 0; } - if (points_at.nr !match_points_at(refname, sha1)) + if (points_at.nr !match_points_at(refname, oid-hash)) return 0; if (!filter-lines) { @@ -242,7 +242,7 @@ static int show_reference(const char *refname, const unsigned char *sha1, return 0; } printf(%-15s , refname); - show_tag_lines(sha1, filter-lines); + show_tag_lines(oid, filter-lines); putchar('\n'); } @@ -260,8 +260,6 @@ static int list_tags(const char **patterns, int lines, struct commit_list *with_commit, int sort) { struct tag_filter filter; - struct each_ref_fn_sha1_adapter wrapped_show_reference = - {show_reference, (void *)filter}; filter.patterns = patterns; filter.lines = lines; @@ -270,7 +268,7 @@ static int list_tags(const char **patterns, int lines, memset(filter.tags, 0, sizeof(filter.tags)); filter.tags.strdup_strings = 1; - for_each_tag_ref(each_ref_fn_adapter, wrapped_show_reference); + for_each_tag_ref(show_reference, (void *)filter); if (sort) { int i; if ((sort SORT_MASK) == VERCMP_SORT) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 05/56] register_ref(): rewrite to take an object_id argument
From: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: Michael Haggerty mhag...@alum.mit.edu Signed-off-by: brian m. carlson sand...@crustytoothpaste.net --- bisect.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/bisect.c b/bisect.c index 0848d91..03d5cd9 100644 --- a/bisect.c +++ b/bisect.c @@ -400,16 +400,16 @@ struct commit_list *find_bisection(struct commit_list *list, return best; } -static int register_ref(const char *refname, const unsigned char *sha1, +static int register_ref(const char *refname, const struct object_id *oid, int flags, void *cb_data) { if (!strcmp(refname, bad)) { current_bad_oid = xmalloc(sizeof(*current_bad_oid)); - hashcpy(current_bad_oid-hash, sha1); + oidcpy(current_bad_oid, oid); } else if (starts_with(refname, good-)) { - sha1_array_append(good_revs, sha1); + sha1_array_append(good_revs, oid-hash); } else if (starts_with(refname, skip-)) { - sha1_array_append(skipped_revs, sha1); + sha1_array_append(skipped_revs, oid-hash); } return 0; @@ -417,10 +417,7 @@ static int register_ref(const char *refname, const unsigned char *sha1, static int read_bisect_refs(void) { - struct each_ref_fn_sha1_adapter wrapped_register_ref = - {register_ref, NULL}; - - return for_each_ref_in(refs/bisect/, each_ref_fn_adapter, wrapped_register_ref); + return for_each_ref_in(refs/bisect/, register_ref, NULL); } static void read_bisect_paths(struct argv_array *array) -- 2.4.0 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 00/56] Convert parts of refs.c to struct object_id
This is a conversion of parts of refs.c to use struct object_id. refs.c, and the for_each_ref series of functions explicitly, is the source for many instances of object IDs in the codebase. Therefore, it makes sense to convert this series of functions to provide a basis for further conversions. Changes from v2: * Adopt Michael Haggerty's patch series that uses an adapter function. * Squash some of these patches together where it makes sense in order to reduce the quantity of patches. This does only slightly more than my original series, just in a different way, with a larger number of much smaller patches. If the quantity of patches is too large for people's tastes, I can do a v4 based off of v2 that has less of this problem. Converting most of the for_each_ref series of functions all at once is important to avoid confusing interface mismatches. I intend to send smaller patch series in the future to make reviewers' lives easier. This passes the testsuite at each step and is based off of master. Also available in branch oid-refs-adapter-squashed at: https://git.crustytoothpaste.net/git/bmc/git.git https://github.com/bk2204/git.git Michael Haggerty (55): each_ref_fn: change to take an object_id parameter builtin/rev-parse: rewrite to take an object_id argument handle_one_ref(): rewrite to take an object_id argument register_ref(): rewrite to take an object_id argument append_ref(): rewrite to take an object_id argument add_pending_uninteresting_ref(): rewrite to take an object_id argument get_name(): rewrite to take an object_id argument builtin/fetch: rewrite to take an object_id argument grab_single_ref(): rewrite to take an object_id argument name_ref(): rewrite to take an object_id argument builtin/pack-objects: rewrite to take an object_id argument show_ref_cb(): rewrite to take an object_id argument builtin/reflog: rewrite ref functions to take an object_id argument add_branch_for_removal(): rewrite to take an object_id argument add_branch_for_removal(): don't set util field of string_list entries builtin/remote: rewrite functions to take object_id arguments show_reference(): rewrite to take an object_id argument append_matching_ref(): rewrite to take an object_id argument builtin/show-branch: rewrite functions to take object_id arguments append_one_rev(): rewrite to work with object_id builtin/show-branch: rewrite functions to work with object_id cmd_show_branch(): fix error message fsck: change functions to use object_id builtin/show-ref: rewrite to use object_id show_ref(): convert local variable peeled to object_id builtin/show-ref: rewrite to take an object_id argument append_similar_ref(): rewrite to take an object_id argument http-backend: rewrite to take an object_id argument show_head_ref(): convert local variable unused to object_id add_ref_decoration(): rewrite to take an object_id argument add_ref_decoration(): convert local variable original_sha1 to object_id string_list_add_one_ref(): rewrite to take an object_id argument add_one_ref(): rewrite to take an object_id argument remote: rewrite functions to take object_id arguments register_replace_ref(): rewrite to take an object_id argument handle_one_reflog(): rewrite to take an object_id argument add_info_ref(): rewrite to take an object_id argument handle_one_ref(): rewrite to take an object_id argument shallow: rewrite functions to take object_id arguments submodule: rewrite to take an object_id argument write_refs_to_temp_dir(): convert local variable sha1 to object_id write_one_ref(): rewrite to take an object_id argument find_symref(): rewrite to take an object_id argument find_symref(): convert local variable unused to object_id upload-pack: rewrite functions to take object_id arguments send_ref(): convert local variable peeled to object_id mark_complete(): rewrite to take an object_id argument clear_marks(): rewrite to take an object_id argument mark_complete_oid(): new function, taking an object_oid mark_complete(): remove unneeded arguments rev_list_insert_ref_oid(): new function, taking an object_oid rev_list_insert_ref(): remove unneeded arguments each_ref_fn_adapter(): remove adapter warn_if_dangling_symref(): convert local variable junk to object_id struct ref_lock: convert old_sha1 member to object_id brian m. carlson (1): refs: convert struct ref_entry to use struct object_id Documentation/technical/api-ref-iteration.txt | 2 +- bisect.c | 8 +- builtin/branch.c | 4 +- builtin/checkout.c| 4 +- builtin/describe.c| 12 +-- builtin/fetch.c | 15 ++-- builtin/for-each-ref.c| 5 +- builtin/fsck.c| 20 ++--- builtin/name-rev.c| 6 +-
Re: [PATCH v2 1/2] for-each-ref: re-structure code for moving to 'ref-filter'
I do not see much point in renaming between these two. The latter makes it sound as if this is only for filtering and from that angle of view is probably a worse name. If you do not think of a better one, and if you are going to name the array that contains this thing ref_list, calling ref_list_item would be following suit to what string-list did. Well I just wanted to keep it related to 'ref-filter', I think 'ref_list_item' sounds better after seeing your point of view. I somehow had an impression that we are trying to move away from calling the name of objects as sha1[] as a longer term goal? I do not think it is particularly a good idea to start using struct object_id in this series (it can be done after everything is done and you still have time left in GSoC), but I do not see how much value this interim renaming (because eventually we would change not just name but type, and the final name will _not_ be sha1[] but more closer to object name) adds value. I did that to resemble whats usually being used in similar structures, a simple grep of sha1[20]; resulted in 344 uses. I didn't know about the we are trying to move away from calling the name of objects as sha1[]. Will leave it as objectname then. You didn't explain why you reordered the fields, either. Were you planning to make the name[] field to flex-array to reduce need for one level of redirection or something? Yes! exactly why the re-order, was going to rebase it and squash it in, if the code seemed to be up and running. I agree that grab part of grab_ref_cbdata sounds unprofessional, and using ref_filter_ to signal that this callback data is about ref-filter API might be a good idea (I do not think the original is too bad, either, though). I do not think you would use this struct anywhere other than as the callback data; you would want to end its name with _cbdata, not just _data, to make it clear why these two unrelated things are in a single struct (the only time these two concepts, operation and operatee, meet is when they need to be passed to an apply operation to operatee function; there is no such this set of operatee always are for this operation association between them---which is what I mean by 'two unrelated things'). sure, will do :) thanks for putting that out. It was perfectly good name as a file-scope static; within the context of 'for-each-ref' implementation, when every somebody says atom, you would know it is those %(atomic-data-item) things, and parse_atom() would be a helper function to do so. But it is *WAY* too generic a name to make public, where you are naming things in the whole context of Git implementation. If you used the word atom while discussing formatting done with git for-each-ref with somebody else, it would be unambiguously clear what you mean; you wouldn't say I am writing a function to parse 'atoms' in Git---that's too broad and you will get 'atom', in what sense? in response. Ditto. Yes, that does seem to be too vague for a public function name, will amend it. As long as this will stay private within the new ref-filter.c after the move, this name is OK. That'll mostly stay private, if required will change the name along. I see fallouts from the two renamed fields in the above hunks. Was the rename necessary? refinfo keeps two names (ref and object) and calling one refname made perfect sense (and calling other objectname did, too). Has anything around its use changed to invalidate that rationale after the structure was renamed? I guess it was unnecessary, my bad. When we say 'flag', it is obvious that it is a flag word, i.e. a word that holds collection of flags. Otherwise, we would have named each unsigned foo_flag : 1 with meaningful names. Was it necessary to make the field name longer? Just felt flags to be more descriptive, well Otherwise, we would have named each unsigned foo_flag : 1 with meaningful names. makes sense. @@ -688,7 +702,7 @@ static void populate_value(struct refinfo *ref) v-s = xstrdup(buf + 1); } continue; -} else if (!deref grab_objectname(name, ref-objectname, v)) { +} else if (!deref grab_objectname(name, ref-sha1, v)) { continue; Mental note: grab_objectname() still remains, so I'd guess that it will not be moved from this file or it will stay private after it is moved. It will be private. Another mental note: it was a consistent naming for the function to grab objectname to store the result into objectname[] field. Now it stores into sha1[] field. yes, seems a bit off. Yuck; I can see what you are doing but can you imitate what the more experienced people (e.g. peff, mhagger) do when restructuring existing code and do things in smaller increments? For example, I think it should be a separate preparatory patch, even before these renames of structures, fields and functions, to extract this helper function out
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Junio C Hamano gits...@pobox.com writes: Allen Hubbe alle...@gmail.com writes: Looking closer at this and the other test cases, they are inconsistent about using .mailrc, ~/.mailrc, and $(pwd)/.mailrc. This would add another one, $HOME/.mailrc. In t9001, I see two tests on mailrc: ... So I do not see any reason to change most of these; except that the target of 'echo' should be changed from ~/.mailrc to $HOME/.mailrc. FYI, I have tentatively queued this on top of your patch. Please see git log master..cf954075 to double check. Thanks. -- 8 -- Subject: [PATCH] t9001: write $HOME/, not ~/, to help shells without tilde expansion Even though it is in POSIX, we do not have to use it, only to hurt shells that may lack the support. The .mailrc test tries to define an alias in .mailrc in the home directory by shell redirection, and then tries to see ~/.mailrc in config is tilde-expanded by Git without help from shell. So the creation should become $HOME/ to be portable for shells that may lack tilde expansion but the reference should be done as ~/.mailrc. The sendmail one refers to the file from the configuration with full path, so it does not need to know that $HOME during the test run is set to the current trash directory. Signed-off-by: Junio C Hamano gits...@pobox.com --- t/t9001-send-email.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh index b04d263..c5c6867 100755 --- a/t/t9001-send-email.sh +++ b/t/t9001-send-email.sh @@ -1537,7 +1537,7 @@ test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' ' test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' ' clean_fake_sendmail - echo alias sbd some...@example.org ~/.mailrc + echo alias sbd some...@example.org $HOME/.mailrc git config --replace-all sendemail.aliasesfile ~/.mailrc git config sendemail.aliasfiletype mailrc git send-email \ @@ -1552,7 +1552,7 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' ' test_expect_success $PREREQ 'sendemail.aliasfiletype=sendmail' ' clean_fake_sendmail rm -fr outdir git format-patch -1 -o outdir - cat ~/.tmp-email-aliases -\EOF + cat ./.tmp-email-aliases -\EOF alice: Alice W Land a...@example.com bob: Robert Bobbyton b...@example.com # this is a comment -- 2.4.1-455-ga49e496 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Mark trailing whitespace error in del lines of diff
Christian Brabandt cbli...@256bit.org, Christian Brabandt c...@256bit.org writes: As far as I can see, this does not break any tests and also the behaviour of git-diff --check does not change. Even if this change introduced a bug that changed the behaviour (e.g. say, exited with failure status code when only preimage had errors), I wouldn't be surprised if no existing test caught such a breakage. Because the existing tests were written with the assumption that the code to check whitespace breakages would never look at preimage, it is plausible that no preimage line used in the test has any whitespace error in the first place. In other words, you'd need to add new tests that change preimage lines with various kinds of whitespace errors into postimage lines with and without whitespace errors, and run diff with various combinations of the existing set of core.whitespace values as well as your new one. But as I said in the other message, I think that the approach this patch takes goes in a wrong direction. Instead of adding a single check and highlight this and only kind of breakage on preimage option as a new kind to existing what kind of use of whitespaces are errors set, it would be more sensible to add a single check and highlight breakages on preimage lines as well option that is orthogonal to the existing ones that specify what kind of use of whitespaces are errors. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Allen Hubbe alle...@gmail.com writes: Thanks for letting me know. Are you still expecting v6 from me then? The other thing you asked for was a change in the documentation: just mention the email programs' documentation, and describe the exceptions. Could you fetch from me and then run: $ git log --reverse -3 -p 6b733ee4ba330e1187017895b8426dd9171c33b8 to see if you agree with the result? That is what I queued on 'pu' for now with my fixups. We have not heard from Eric on this round yet, so he (and others) may have further input, but as far as I am concerned, that one looked more or less ready to be merged down to 'next', except for the documentation part, which I haven't had a chance to look at the results and may need further AsciiDoc mark-up fixes. Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] http-backend: spool ref negotiation requests to buffer
On 20 May 2015 at 03:37, Jeff King p...@peff.net wrote: + /* partial read from read_in_full means we hit EOF */ + len += cnt; + if (len alloc) { + *out = buf; + warning(request size was %lu, (unsigned long)len); + return len; + } Jeff: This patch appears to work well -- the only complaint I have is that I now have warning: request size was NNN all over my error logs. :) Is it supposed to convey an actual warning message, or is it merely a debug statement? Best, -- Konstantin Ryabitsev Sr. Systems Administrator Linux Foundation Collab Projects 541-224-6067 Montréal, Québec -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Implementing git-am -3 with git-apply -3?
Hi Junio, I noticed that you implemented a 3-way merge fallback[1] in git-apply that is meant to be similar to git-am's. I wonder if it is possible to implement the 3-way merge in git-am using git-apply. Are there any issues/deficiencies that I need to be aware of? So far, I noticed that: * git-apply does not handle renames in the index. * It could probably try harder at merging submodules (perhaps by using merge_submodule()?) [1] http://thread.gmane.org/gmane.comp.version-control.git/201238 Thanks, Paul -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark trailing whitespace error in del lines of diff
Currently git-diff only highlights trailing whitespace in the new lines (prefixed with '+'), thus it is not visible in the deleted lines (prefixed with '-'). Therefore introduce a new configuration variable for the core.whitespace setting blank-at-eol-old (default off) that will highlight trailing whitespace in those lines as well. Signed-off-by: Christian Brabandt c...@256bit.org --- Hi, please be gentle, this is the first time I contribute to the git development. Here is my use case: I have been working in a team repository, reformatting the source and wondered, why my reformatting did introduce some trailing whitespace. I suspected a bug in Vim and started to debug it, until I found out, that git-diff simply does not show trailing whitespace in the deleted lines. Therefore, I'd like to have an option, to also show trailing whitespace in the deleted lines of a diff. So here is the patch. As far as I can see, this does not break any tests and also the behaviour of git-diff --check does not change. Documentation/config.txt | 2 ++ cache.h | 1 + diff.c | 8 +++- ws.c | 8 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 0f668bb..f73f0f7 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -670,6 +670,8 @@ core.whitespace:: + * `blank-at-eol` treats trailing whitespaces at the end of the line as an error (enabled by default). +* `blank-at-eol-old` like `blank-at-eol`, but for the deleted lines + of a patch (i.e. those preceeded with a '-') (not enabled by default) * `space-before-tab` treats a space character that appears immediately before a tab character in the initial indent part of the line as an error (enabled by default). diff --git a/cache.h b/cache.h index 1f4226b..811b640 100644 --- a/cache.h +++ b/cache.h @@ -1618,6 +1618,7 @@ void shift_tree_by(const unsigned char *, const unsigned char *, unsigned char * #define WS_CR_AT_EOL 01000 #define WS_BLANK_AT_EOF02000 #define WS_TAB_IN_INDENT 04000 +#define WS_BLANK_AT_EOL_OLD01 #define WS_TRAILING_SPACE (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF) #define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8) #define WS_TAB_WIDTH_MASK077 diff --git a/diff.c b/diff.c index 7500c55..4245956 100644 --- a/diff.c +++ b/diff.c @@ -1254,10 +1254,16 @@ static void fn_out_consume(void *priv, char *line, unsigned long len) const char *color = diff_get_color(ecbdata-color_diff, line[0] == '-' ? DIFF_FILE_OLD : DIFF_PLAIN); + const char *ws = diff_get_color(ecbdata-color_diff, DIFF_WHITESPACE); + ecbdata-lno_in_preimage++; if (line[0] == ' ') ecbdata-lno_in_postimage++; - emit_line(ecbdata-opt, color, reset, line, len); + if (*ws ecbdata-ws_rule WS_BLANK_AT_EOL_OLD) + ws_check_emit(line, len, ecbdata-ws_rule, + ecbdata-opt-file, color, reset, ws); + else + emit_line(ecbdata-opt, color, reset, line, len); } else { ecbdata-lno_in_postimage++; emit_add_line(reset, ecbdata, line + 1, len - 1); diff --git a/ws.c b/ws.c index ea4b2b1..09e04f0 100644 --- a/ws.c +++ b/ws.c @@ -18,6 +18,7 @@ static struct whitespace_rule { { indent-with-non-tab, WS_INDENT_WITH_NON_TAB, 0 }, { cr-at-eol, WS_CR_AT_EOL, 1 }, { blank-at-eol, WS_BLANK_AT_EOL, 0 }, + { blank-at-eol-del, WS_BLANK_AT_EOL_OLD, 0, 1 }, { blank-at-eof, WS_BLANK_AT_EOF, 0 }, { tab-in-indent, WS_TAB_IN_INDENT, 0, 1 }, }; @@ -170,11 +171,14 @@ static unsigned ws_check_emit_1(const char *line, int len, unsigned ws_rule, } /* Check for trailing whitespace. */ - if (ws_rule WS_BLANK_AT_EOL) { + if ((ws_rule WS_BLANK_AT_EOL) || (ws_rule WS_BLANK_AT_EOL_OLD)) { for (i = len - 1; i = 0; i--) { if (isspace(line[i])) { trailing_whitespace = i; - result |= WS_BLANK_AT_EOL; + if (ws_rule WS_BLANK_AT_EOL) + result |= WS_BLANK_AT_EOL; + else + result |= WS_BLANK_AT_EOL_OLD; } else break; -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
On Mon, May 25, 2015 at 9:58 PM, Junio C Hamano gits...@pobox.com wrote: Allen Hubbe alle...@gmail.com writes: Thanks for letting me know. Are you still expecting v6 from me then? The other thing you asked for was a change in the documentation: just mention the email programs' documentation, and describe the exceptions. Could you fetch from me and then run: $ git log --reverse -3 -p 6b733ee4ba330e1187017895b8426dd9171c33b8 to see if you agree with the result? That is what I queued on 'pu' for now with my fixups. It looks good to me. How would you like me to proceed? I assume you would like your patch on top of mine will stay, to use HOME instead of tilde. Or, would you like me to use HOME in my v6, too? Should I send you v6 like v5, but with the documentation fixed, or would you now prefer a separate patch on top of that to fix the documentation? I can do either, and you would be welcome to rebase/fixup the second patch into the earlier one with my sign off. We have not heard from Eric on this round yet, so he (and others) may have further input, but as far as I am concerned, that one looked more or less ready to be merged down to 'next', except for the documentation part, which I haven't had a chance to look at the results and may need further AsciiDoc mark-up fixes. Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Junio C Hamano gits...@pobox.com writes: Junio C Hamano gits...@pobox.com writes: FYI, I have tentatively queued this on top of your patch. Please see git log master..cf954075 to double check. Sorry but I had a typo there... git format-patch -1 -o outdir - cat ~/.tmp-email-aliases -\EOF + cat ./.tmp-email-aliases -\EOF This should just be cat .tmp-email-aliases -\EOF -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Mark trailing whitespace error in del lines of diff
On Mon, May 25, 2015 at 04:27:40PM -0700, Junio C Hamano wrote: brian m. carlson sand...@crustytoothpaste.net writes: My use case is determining whether a patch to a pristine-tar repository introduced trailing whitespace (which is not okay) or just left it there (which is okay). In your use case, where keeping trailing blank that is otherwise not OK is fine only when the breakage was inherited from the preimage, wouldn't it be equally fine to keep other kinds of breakages as long as they were inherited from the preimage? E.g. The original used 8-space as leading indent, and you would not use that for your new lines, but the breakage was inherited from the preimage would want to be treated the same way, no? Why trailing blanks so special? The goal is to keep the code as similar as possible to the old code, since this is third-party code. If you're changing the whitespace significantly, your changes are too invasive. If you're inserting lines, you shouldn't be adding trailing whitespace, but keeping upstream's bizarre indent would be acceptable. Trailing blanks aren't necessarily special, but they are the most common and the easiest to fix (or not introduce) on a piecemeal basis. I agree that a more generic solution would be better. If the implementation were addition of a new option to check and mark all kinds of errors core.whitespace would catch for new lines also for old lines, then it would be a somewhat different story. I personally do not find such an option interesting, but at least I can understand why some people might find it useful. The vast majority of the whitespace errors I see are blank-at-eol, so I felt this change was, if anything, a good first step. Having read your response, I agree the generic solution is preferable. [Footnote] *1* To support your use case with the ultimate ease-of-use, it would be best if the new option were to squelch the whitespace error on the new line when it was inherited from the old line, which is different from showing and marking the breakage on the old line. But I do not think it can be implemented sanely, so I will not go there. I'd rather see that there's an error on both so that I have the knowledge when reviewing a patch. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187 signature.asc Description: Digital signature
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
On Mon, May 25, 2015 at 5:35 PM, Junio C Hamano gits...@pobox.com wrote: Junio C Hamano gits...@pobox.com writes: Junio C Hamano gits...@pobox.com writes: FYI, I have tentatively queued this on top of your patch. Please see git log master..cf954075 to double check. Sorry but I had a typo there... git format-patch -1 -o outdir - cat ~/.tmp-email-aliases -\EOF + cat ./.tmp-email-aliases -\EOF This should just be cat .tmp-email-aliases -\EOF Thanks for letting me know. Are you still expecting v6 from me then? The other thing you asked for was a change in the documentation: just mention the email programs' documentation, and describe the exceptions. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Mark trailing whitespace error in del lines of diff
brian m. carlson sand...@crustytoothpaste.net writes: I like this idea. I don't. My use case is determining whether a patch to a pristine-tar repository introduced trailing whitespace (which is not okay) or just left it there (which is okay). In your use case, where keeping trailing blank that is otherwise not OK is fine only when the breakage was inherited from the preimage, wouldn't it be equally fine to keep other kinds of breakages as long as they were inherited from the preimage? E.g. The original used 8-space as leading indent, and you would not use that for your new lines, but the breakage was inherited from the preimage would want to be treated the same way, no? Why trailing blanks so special? So, from that point of view, your use case does not justify this particular implementation that special-cases trailing blanks on deleted lines and mark them [*1*]. If the implementation were addition of a new option to check and mark all kinds of errors core.whitespace would catch for new lines also for old lines, then it would be a somewhat different story. I personally do not find such an option interesting, but at least I can understand why some people might find it useful. [Footnote] *1* To support your use case with the ultimate ease-of-use, it would be best if the new option were to squelch the whitespace error on the new line when it was inherited from the old line, which is different from showing and marking the breakage on the old line. But I do not think it can be implemented sanely, so I will not go there. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 3/3] http-backend: spool ref negotiation requests to buffer
On Mon, May 25, 2015 at 10:07:50PM -0400, Konstantin Ryabitsev wrote: On 20 May 2015 at 03:37, Jeff King p...@peff.net wrote: + /* partial read from read_in_full means we hit EOF */ + len += cnt; + if (len alloc) { + *out = buf; + warning(request size was %lu, (unsigned long)len); + return len; + } Jeff: This patch appears to work well -- the only complaint I have is that I now have warning: request size was NNN all over my error logs. :) Is it supposed to convey an actual warning message, or is it merely a debug statement? Whoops, yeah, it was just for debugging. I missed that one when sending out the patch. Junio, the squashable patch is below (on jk/http-backend-deadlock-2.2), and it looks like nothing has hit next yet. But you did do some up-merging of the topic. Let me know if you would prefer to just have a patch on top. diff --git a/http-backend.c b/http-backend.c index d1333b8..6bf139b 100644 --- a/http-backend.c +++ b/http-backend.c @@ -295,7 +295,6 @@ static ssize_t read_request(int fd, unsigned char **out) len += cnt; if (len alloc) { *out = buf; - warning(request size was %lu, (unsigned long)len); return len; } -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] submodule documentation: Reorder introductory paragraphs
Stefan Beller sbel...@google.com writes: DESCRIPTION --- +This command will inspect, update and manage submodules. +Submodules allow you to keep another Git repository in a subdirectory +of your repository. The other repository has its own history,... The first line somehow bothered me, so I took a random sample of commands I often use: git log Shows the commit logs. git show Shows one or more objects (blobs, trees, tags and commits). git commit Stores the current contents of the index in a new commit along with a log message from the user describing the changes. git diff Show changes between the working tree and the index or a tree, changes between the index and a tree, changes between two trees, changes between two blob objects, or changes between two files on disk. git push Updates remote refs using local refs, while sending objects necessary to complete the given refs. I _think_ what bothered me was This command (drawing the reaction eh, what other command are you going to talk about in the help page for this command?). Perhaps Inspects, updates and manages submodules. may match the style of other help pages better. On the other hand, I probably would not have felt such a strong strangeness if it were described like this: This command can help you inspect, update, and manage submodules. I haven't analized it enough to say why it is, but I suspect it has something to do with (my own) perception that git submodule is not very essential to do any of these things (i.e. .gitmodules is a very simple text file), but is primarily a helpful wrapper. The description of git config, on which I have a similar perception, seem to match ;-) git config You can query/set/replace/unset options with this command. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Mark trailing whitespace error in del lines of diff
On Mon, May 25, 2015 at 11:11:34PM +0200, Christian Brabandt wrote: Here is my use case: I have been working in a team repository, reformatting the source and wondered, why my reformatting did introduce some trailing whitespace. I suspected a bug in Vim and started to debug it, until I found out, that git-diff simply does not show trailing whitespace in the deleted lines. Therefore, I'd like to have an option, to also show trailing whitespace in the deleted lines of a diff. So here is the patch. I like this idea. My use case is determining whether a patch to a pristine-tar repository introduced trailing whitespace (which is not okay) or just left it there (which is okay). As far as I can see, this does not break any tests and also the behaviour of git-diff --check does not change. Perhaps you'd care to implement a test or two to make sure that this continues to work properly? Documentation/config.txt | 2 ++ cache.h | 1 + diff.c | 8 +++- ws.c | 8 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 0f668bb..f73f0f7 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -670,6 +670,8 @@ core.whitespace:: + * `blank-at-eol` treats trailing whitespaces at the end of the line as an error (enabled by default). +* `blank-at-eol-old` like `blank-at-eol`, but for the deleted lines You might want to insert works before like so that it's a complete sentence. + of a patch (i.e. those preceeded with a '-') (not enabled by default) I believe this should be preceded. -- brian m. carlson / brian with sandals: Houston, Texas, US +1 832 623 2791 | http://www.crustytoothpaste.net/~bmc | My opinion only OpenPGP: RSA v4 4096b: 88AC E9B2 9196 305B A994 7552 F1BA 225C 0223 B187 signature.asc Description: Digital signature
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Allen Hubbe alle...@gmail.com writes: Could you fetch from me and then run: $ git log --reverse -3 -p 6b733ee4ba330e1187017895b8426dd9171c33b8 to see if you agree with the result? That is what I queued on 'pu' for now with my fixups. It looks good to me. How would you like me to proceed? I assume you would like your patch on top of mine will stay, to use HOME instead of tilde. Or, would you like me to use HOME in my v6, too? Should I send you v6 like v5, but with the documentation fixed, or would you now prefer a separate patch on top of that to fix the documentation? It probably should be two patches. Your sendmail thing with docs and tests as one patch (with $HOME in test), and fix to mailrc tests I did (minus the part that fixes your sendmail test, which should now become unnecessary) on top. If the documentation I queued on 'pu' formats well already (which I cannot check myself until tomorrow), then I'd guess the above would be like squashing 8b8fb5a into dc6183c and then 6b733ee on top, I think. 6b733ee t9001: write $HOME/, not ~/, to help shells without tilde expansion 8b8fb5a git-send-email doc: refer to upstream document for alias format dc6183c send-email: add sendmail email aliases format -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Implementing git-am -3 with git-apply -3?
Paul Tan pyoka...@gmail.com writes: I wonder if it is possible to implement the 3-way merge in git-am using git-apply. Are there any issues/deficiencies that I need to be aware of? Anything is possible ;-) Even though I suspect it might be of significant complexity, it certainly would be nice if apply -3 could be taught to do everything am -3 would do. * git-apply does not handle renames in the index. True. The patch application does not really have a global picture, and that is one of the reasons why I foresee significant complexity as I said above. The three-way merge with synthesized virtual base tree done in am -3 makes use of established and independent component that is merge-recursive, and that makes things easier and keeps things cleaner. * It could probably try harder at merging submodules (perhaps by using merge_submodule()?) I am not sure what you mean. I thought it punts what am -3 would punt on, and handles what am -3 would handle. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-new-workdir: add windows compatibility
Daniel Smith dansmit...@gmail.com writes: When running on Windows in MinGW, creating symbolic links via ln always failed. Using mklink instead of ln is the recommended method of creating links on Windows: http://stackoverflow.com/questions/18641864/git-bash-shell-fails-to-create-symbolic-links Script now branches on Windows to use mklink. This change should not affect unix systems. Signed-off-by: Daniel Smith dansmit...@gmail.com Has been tested on Windows 8.1 and OS X Yosemite. --- Swap the Has been tested... and Signed-off-by: lines. I'll defer to Windows folks if mklink is a sensible thing to use or not; I have no first-hand experience with Windows, but only heard that links are for admin user only or something like that, so I want to hear from people whose judgement on Windows matters I trust. +iswindows () { + [[ -n $WINDIR ]]; +} Please don't add unnecessary bash-isms. We have kept this script usable without stepping out of POSIX. test -n $WINDIR -git_dir=$(cd $git_dir pwd) || exit 1 +if iswindows +then + git_dir=$(cd $git_dir; cmd.exe /c cd) || exit 1 +else + git_dir=$(cd $git_dir pwd) || exit 1 +fi Indentation of lines inside a new block is done with one more level of HT in our scripts, not with just one SP. - ln -s $git_dir/$x $new_workdir/.git/$x || failed + if iswindows + then Move these into a helper shell function, starting from here... + if test -d $git_dir/$x + then + # create directory symbolic link + isdir=/d + fi + # convert path separator to backslash + targetPath=$(sed -e 's#^J:##' -e 's#/#\\#g' $git_dir/$x) + cmd.exe /c mklink $isdir \$new_workdir/.git/$x\ \$targetPath\ || failed ... up to here. Also a few points about these new lines: * Use indentation when doing nested if/then/if/then/fi/fi block, i.e. if isWindows then if test -d ... then isdir=/d fi target=.. cmd.exe /c ... fi * is a bash-ism, isn't it? * Use of # as s/// separator, when slash is not involved, looks ugly and makes it harder to read. * Is J: drive something special (unlike C: or D: drives)? * Can computation of targetPath fail? IOW, shouldn't that line end with ? * Share || failed between this part and POSIX part, i.e. if isWindows then ln_s_win $new_workdir $x else ln -s $git_dir/$x $new_workdir'.git/$x fi || failed where ln_s_win would be the helper shell function I suggested. ln_s_win () { if test -d $git_dir/$2 then isdir=/d fi target=$(printf %s $git_dir/$2 | sed -e ...) cmd.exe /c mklink $isdir ... } + else + ln -s $git_dir/$x $new_workdir/.git/$x || failed + fi done # commands below this are run in the context of the new workdir Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5 1/1] send-email: Add sendmail email aliases format
Junio C Hamano gits...@pobox.com writes: It probably should be two patches. Your sendmail thing with docs and tests as one patch (with $HOME in test), and fix to mailrc tests I did (minus the part that fixes your sendmail test, which should now become unnecessary) on top. If the documentation I queued on 'pu' formats well already (which I cannot check myself until tomorrow), then I'd guess the above would be like squashing 8b8fb5a into dc6183c and then 6b733ee on top, I think. 6b733ee t9001: write $HOME/, not ~/, to help shells without tilde expansion 8b8fb5a git-send-email doc: refer to upstream document for alias format dc6183c send-email: add sendmail email aliases format Well, I lied [*1*]. I think the documentation part of what is in 'pu' formats fine, so let me just clean them up and push the result out for your final review. Give me a few hours (leaving time for dinner and etc., too). [Footnote] *1* My Git time is spent on in a terminal-only environment, a virtual machine running somewhere in Google datacenters, and when I am home working from a Chromebook via ssh, I lack a convenient way to grab a single file out of there to view in the browser locally. The virtual machine does let me upload to Google Drive and I can grab a file from there to my Chromebook, and that is what I did to see what the AsciiDoc formatted result looked like just now ;-) -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html