{"thread":{"id":"13512","subject":"mergetool feature request - select remote or local","startedAt":"2008-05-14T11:21:00Z","lastAt":"2008-05-15T01:25:33Z","messageCount":5,"participants":["Caleb Cushing","Junio C Hamano","Daniel Barkalow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"76939","messageId":"200805140721.13719.xenoterracide@gmail.com","threadId":"13512","inReplyTo":null,"subject":"mergetool feature request - select remote or local","fromName":"Caleb Cushing","fromEmail":"xenoterracide@gmail.com","sentAt":"2008-05-14T11:21:00Z","receivedAt":"2008-05-14T11:21:00Z","isPatch":false,"sender":{"key":"xenoterracide@gmail.com","avatar":"https://gravatar.com/avatar/af3f0745dfa0ea9c4ee551d7d0a3cfe7ba8d229754c11678ab2ed23c3fa57065?d=mp&s=160"},"body":"sometimes when merge-ing fast forward doesn't work. but you know what the \nresolution you want is.\n\nexample (current behavior)\nNormal merge conflict for 'css/main.css':\n  {local}: modified\n  {remote}: modified\nHit return to start merge resolution tool (vimdiff):\n\nbut I don't want to. I know the remote updates are right. I could do a git \ncheckout remotebranch filename but when you have 20 files that need updating \nthis is annoying\n\nmy suggestion is this\nNormal merge conflict for 'css/main.css':\n  {local}: modified\n  {remote}: modified\nUse (l)local or (r)remote or (m)anual? \n\nalso in the event of having 20 files with this issue it would be nice to have \nan option after first starting mergetool for remote all or local all.\n\n(note: I am not subscribed to the list)\n-- \nCaleb Cushing\n\nmy blog http://xenoterracide.blogspot.com\n"},{"id":"76962","messageId":"7vzlqsok0y.fsf@gitster.siamese.dyndns.org","threadId":"13512","inReplyTo":"200805140721.13719.xenoterracide@gmail.com","subject":"Re: mergetool feature request - select remote or local","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-14T17:47:09Z","receivedAt":"2008-05-14T17:47:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Caleb Cushing <xenoterracide@gmail.com> writes:\n\n> sometimes when merge-ing fast forward doesn't work. but you know what the \n> resolution you want is.\n>\n> example (current behavior)\n> Normal merge conflict for 'css/main.css':\n>   {local}: modified\n>   {remote}: modified\n> Hit return to start merge resolution tool (vimdiff):\n>\n> but I don't want to. I know the remote updates are right. I could do a git \n> checkout remotebranch filename but when you have 20 files that need updating \n> this is annoying\n\nI never understood why people are using git and not ftp when they say the\nother side is always right, but I see this comes up every once in a while,\nso it would probably be a good thing to support.\n\n> my suggestion is this\n> Normal merge conflict for 'css/main.css':\n>   {local}: modified\n>   {remote}: modified\n> Use (l)local or (r)remote or (m)anual? \n\nThe above \"(l)local\" and \"(m)anual\" look inconsistent, and the wording\nshould be more like \"local, remote or merge\".\n\n> also in the event of having 20 files with this issue it would be nice to have \n> an option after first starting mergetool for remote all or local all.\n\nThis makes me wonder if you are better off not using mergetool in such a\nsituation.  Instead, perhaps\n\n\t$ git ls-files -u --no-stage | xargs git checkout MERGE_HEAD\n\nmight be a better option?  The attached is a completely untested\nweather-baloon patch.\n\nIf this turns out to be a better approach, perhaps we would further want\nto tweak things to make:\n\n\t$ git checkout --unmerged MERGE_HEAD [--] [<pathspec>...]\n\nto work (if you want \"local\", you would use \"HEAD\" instead of\n\"MERGE_HEAD\").\n\nI would have done so here if \"git checkout\" were still a scripted version,\nbut now it is in C, it would take significantly more effort than it is\nworth just to raise a weatherbaloon.\n\n builtin-ls-files.c |   22 ++++++++++++++++++++++\n 1 files changed, 22 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-ls-files.c b/builtin-ls-files.c\nindex dc7eab8..36b2875 100644\n--- a/builtin-ls-files.c\n+++ b/builtin-ls-files.c\n@@ -181,6 +181,8 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)\n {\n \tint len = prefix_len;\n \tint offset = prefix_offset;\n+\tstatic const char *last_tag_shown;\n+\tstatic struct cache_entry *last_ce_shown;\n \n \tif (len >= ce_namelen(ce))\n \t\tdie(\"git-ls-files: internal error - cache entry not superset of prefix\");\n@@ -206,7 +208,18 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)\n \t}\n \n \tif (!show_stage) {\n+\t\t/*\n+\t\t * Even when not showing stage information, we will call this\n+\t\t * function for each stage.  Omit duplicate output.\n+\t\t */\n+\t\tif ((!tag ||\n+\t\t     (last_tag_shown && !strcmp(last_tag_shown, tag))) &&\n+\t\t    (last_ce_shown &&\n+\t\t     !strcmp(last_ce_shown->name, ce->name)))\n+\t\t\treturn;\n \t\tfputs(tag, stdout);\n+\t\tlast_tag_shown = tag;\n+\t\tlast_ce_shown = ce;\n \t} else {\n \t\tprintf(\"%s%06o %s %d\\t\",\n \t\t       tag,\n@@ -509,6 +522,15 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)\n \t\t\tshow_unmerged = 1;\n \t\t\tcontinue;\n \t\t}\n+\t\tif (!strcmp(arg, \"--no-stage\")) {\n+\t\t\t/*\n+\t\t\t * ... Not really.\n+\t\t\t * Sometimes we would want a list of unmerged paths.\n+\t\t\t */\n+\t\t\tshow_stage = 0;\n+\t\t\tshow_cached = 1;\n+\t\t\tcontinue;\n+\t\t}\n \t\tif (!strcmp(arg, \"-x\") && i+1 < argc) {\n \t\t\texc_given = 1;\n \t\t\tadd_exclude(argv[++i], \"\", 0, &dir.exclude_list[EXC_CMDL]);\n"},{"id":"76973","messageId":"alpine.LNX.1.00.0805141351540.19665@iabervon.org","threadId":"13512","inReplyTo":"7vzlqsok0y.fsf@gitster.siamese.dyndns.org","subject":"Re: mergetool feature request - select remote or local","fromName":"Daniel Barkalow","fromEmail":"barkalow@iabervon.org","sentAt":"2008-05-14T18:40:47Z","receivedAt":"2008-05-14T18:40:47Z","isPatch":false,"sender":{"key":"barkalow@iabervon.org","avatar":"https://avatars.githubusercontent.com/u/55364219?v=4"},"body":"On Wed, 14 May 2008, Junio C Hamano wrote:\n\n> This makes me wonder if you are better off not using mergetool in such a\n> situation.  Instead, perhaps\n> \n> \t$ git ls-files -u --no-stage | xargs git checkout MERGE_HEAD\n> \n> might be a better option?  The attached is a completely untested\n> weather-baloon patch.\n> \n> If this turns out to be a better approach, perhaps we would further want\n> to tweak things to make:\n> \n> \t$ git checkout --unmerged MERGE_HEAD [--] [<pathspec>...]\n> \n> to work (if you want \"local\", you would use \"HEAD\" instead of\n> \"MERGE_HEAD\").\n\nThis is \"for all (or some, by pathspecs) files currently unmerged in the \nindex, resolve them to the version in MERGE_HEAD\", right?\n\n> I would have done so here if \"git checkout\" were still a scripted version,\n> but now it is in C, it would take significantly more effort than it is\n> worth just to raise a weatherbaloon.\n\nLike this (also untested)? (This is missing defaulting to a pathspec of \n'.' if --unmerged is used without any pathspecs)\n\ndiff --git a/builtin-checkout.c b/builtin-checkout.c\nindex 10ec137..0bae1d4 100644\n--- a/builtin-checkout.c\n+++ b/builtin-checkout.c\n@@ -42,6 +42,8 @@ static int post_checkout_hook(struct commit *old, struct commit *new,\n \treturn run_command(&proc);\n }\n \n+static int unmerged;\n+\n static int update_some(const unsigned char *sha1, const char *base, int baselen,\n \t\t       const char *pathname, unsigned mode, int stage)\n {\n@@ -59,6 +61,13 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,\n \thashcpy(ce->sha1, sha1);\n \tmemcpy(ce->name, base, baselen);\n \tmemcpy(ce->name + baselen, pathname, len - baselen);\n+\tif (unmerged) {\n+\t\tint pos = cache_name_pos(ce->name, len);\n+\t\tif (!(pos && pos < active_nr && ce_same_name(active_cache[pos], active_cache[pos + 1]))) {\n+\t\t\tfree(ce);\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n \tce->ce_flags = create_ce_flags(len, 0);\n \tce->ce_mode = create_ce_mode(mode);\n \tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n@@ -508,6 +517,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n \t\t\tBRANCH_TRACK_EXPLICIT),\n \t\tOPT_BOOLEAN('f', NULL, &opts.force, \"force\"),\n \t\tOPT_BOOLEAN('m', NULL, &opts.merge, \"merge\"),\n+\t\tOPT_BOOLEAN( 0 , \"unmerged\", &unmerged, \"check out unmerged paths\"),\n \t\tOPT_END(),\n \t};\n \n"},{"id":"76978","messageId":"7vtzh0n164.fsf@gitster.siamese.dyndns.org","threadId":"13512","inReplyTo":"alpine.LNX.1.00.0805141351540.19665@iabervon.org","subject":"Re: mergetool feature request - select remote or local","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-05-14T19:19:47Z","receivedAt":"2008-05-14T19:19:47Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Daniel Barkalow <barkalow@iabervon.org> writes:\n\n> On Wed, 14 May 2008, Junio C Hamano wrote:\n> ...\n>> If this turns out to be a better approach, perhaps we would further want\n>> to tweak things to make:\n>> \n>> \t$ git checkout --unmerged MERGE_HEAD [--] [<pathspec>...]\n>> \n>> to work (if you want \"local\", you would use \"HEAD\" instead of\n>> \"MERGE_HEAD\").\n>\n> This is \"for all (or some, by pathspecs) files currently unmerged in the \n> index, resolve them to the version in MERGE_HEAD\", right?\n\nYeah, and possibly limited by pathspec as usual.\n\n>> I would have done so here if \"git checkout\" were still a scripted version,\n>> but now it is in C, it would take significantly more effort than it is\n>> worth just to raise a weatherbaloon.\n>\n> Like this (also untested)? (This is missing defaulting to a pathspec of \n> '.' if --unmerged is used without any pathspecs)\n\nLooks easy enough.  Caleb, does this approach fit the situation you\ndescribed better?\n\n> diff --git a/builtin-checkout.c b/builtin-checkout.c\n> index 10ec137..0bae1d4 100644\n> --- a/builtin-checkout.c\n> +++ b/builtin-checkout.c\n> @@ -42,6 +42,8 @@ static int post_checkout_hook(struct commit *old, struct commit *new,\n>  \treturn run_command(&proc);\n>  }\n>  \n> +static int unmerged;\n> +\n>  static int update_some(const unsigned char *sha1, const char *base, int baselen,\n>  \t\t       const char *pathname, unsigned mode, int stage)\n>  {\n> @@ -59,6 +61,13 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen,\n>  \thashcpy(ce->sha1, sha1);\n>  \tmemcpy(ce->name, base, baselen);\n>  \tmemcpy(ce->name + baselen, pathname, len - baselen);\n> +\tif (unmerged) {\n> +\t\tint pos = cache_name_pos(ce->name, len);\n> +\t\tif (!(pos && pos < active_nr && ce_same_name(active_cache[pos], active_cache[pos + 1]))) {\n> +\t\t\tfree(ce);\n> +\t\t\treturn 0;\n> +\t\t}\n> +\t}\n>  \tce->ce_flags = create_ce_flags(len, 0);\n>  \tce->ce_mode = create_ce_mode(mode);\n>  \tadd_cache_entry(ce, ADD_CACHE_OK_TO_ADD | ADD_CACHE_OK_TO_REPLACE);\n> @@ -508,6 +517,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)\n>  \t\t\tBRANCH_TRACK_EXPLICIT),\n>  \t\tOPT_BOOLEAN('f', NULL, &opts.force, \"force\"),\n>  \t\tOPT_BOOLEAN('m', NULL, &opts.merge, \"merge\"),\n> +\t\tOPT_BOOLEAN( 0 , \"unmerged\", &unmerged, \"check out unmerged paths\"),\n>  \t\tOPT_END(),\n>  \t};\n>  \n"},{"id":"77006","messageId":"200805142125.40027.xenoterracide@gmail.com","threadId":"13512","inReplyTo":"7vzlqsok0y.fsf@gitster.siamese.dyndns.org","subject":"Re: mergetool feature request - select remote or local","fromName":"Caleb Cushing","fromEmail":"xenoterracide@gmail.com","sentAt":"2008-05-15T01:25:33Z","receivedAt":"2008-05-15T01:25:33Z","isPatch":false,"sender":{"key":"xenoterracide@gmail.com","avatar":"https://gravatar.com/avatar/af3f0745dfa0ea9c4ee551d7d0a3cfe7ba8d229754c11678ab2ed23c3fa57065?d=mp&s=160"},"body":"On Wednesday 14 May 2008 01:47:09 pm you wrote:\n> I never understood why people are using git and not ftp when they say the\n> other side is always right, but I see this comes up every once in a while,\n> so it would probably be a good thing to support.\n\nwell in my case I'm not particularly sure why fast forward didn't just merge \nthem. Seems like I had resolved these changes in master previously. this \nproblem is most annoying when I am resolving the same issues across multiple \nbranches.\n\n> The above \"(l)local\" and \"(m)anual\" look inconsistent, and the wording\n> should be more like \"local, remote or merge\".\n\nlocal,remote, merge is fine and I used the (m) for example because of how it \nasked me to handle a file existing locally (with mods?) but had been deleted \nin MERGE_HEAD?\n\n> > also in the event of having 20 files with this issue it would be nice to\n> > have an option after first starting mergetool for remote all or local\n> > all.\n>\n> This makes me wonder if you are better off not using mergetool in such a\n> situation.  Instead, perhaps\n>\n>         $ git ls-files -u --no-stage | xargs git checkout MERGE_HEAD\n\nperhaps... I'm not this familiar with git yet.\n\n> might be a better option?  The attached is a completely untested\n> weather-baloon patch.\n>\n> If this turns out to be a better approach, perhaps we would further want\n> to tweak things to make:\n>\n>         $ git checkout --unmerged MERGE_HEAD [--] [<pathspec>...]\n>\n> to work (if you want \"local\", you would use \"HEAD\" instead of\n> \"MERGE_HEAD\").\n\n> Looks easy enough.  Caleb, does this approach fit the situation you\n> described better?\n\num.. is that just a resolution for an merge all (local or remote).\n\nI'm gonna be honest when I say I'm an amateur developer (although I've \nconsidered myself a pretty good admin for a few years) and relatively new to \ngit. So I'm getting a bit lost, but it sounds reasonable. It wouldn't affect \nany files that had been successfully fast forwarded right?\n\nunfortunately I'm not sure how easy testing will be, as this problem doesn't \narise with every merge, but has arisen often enough to be a pita.\n-- \nCaleb Cushing\n\nmy blog http://xenoterracide.blogspot.com\n"}]}