{"thread":{"id":"42147","subject":"[PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","startedAt":"2016-04-26T07:51:20Z","lastAt":"2016-04-27T15:45:08Z","messageCount":16,"participants":["Xiaolong Ye","Stefan Beller","Junio C Hamano","Ye Xiaolong"],"isPatch":true,"patchVersion":6,"patchTotal":4},"messages":[{"id":"284515","messageId":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","threadId":"42147","inReplyTo":null,"subject":"[PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Xiaolong Ye","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-26T07:51:20Z","receivedAt":"2016-04-26T07:51:20Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"Thanks for Junio's reviews and suggestions.\n\nThis version contains the following changes since v5:\n\n - Fix a decl-after-statement in patch 3/4.\n\n - Improve testcases to cover more scenarios and make them more portable and\n   readable.\n\nThanks,\nXiaolong\n\nXiaolong Ye (4):\n  patch-ids: make commit_patch_id() a public helper function\n  format-patch: add '--base' option to record base tree info\n  format-patch: introduce --base=auto option\n  format-patch: introduce format.useAutoBase configuration\n\n Documentation/config.txt           |   5 ++\n Documentation/git-format-patch.txt |  60 +++++++++++++\n builtin/log.c                      | 168 +++++++++++++++++++++++++++++++++++++\n patch-ids.c                        |   2 +-\n patch-ids.h                        |   2 +\n t/t4014-format-patch.sh            | 105 +++++++++++++++++++++++\n 6 files changed, 341 insertions(+), 1 deletion(-)\n\n-- \n2.8.1.343.gda643e5\n\nbase-commit: 3ad15fd5e17bbb73fb1161ff4e9c3ed254d5b243\n"},{"id":"284516","messageId":"1461657084-9223-2-git-send-email-xiaolong.ye@intel.com","threadId":"42147","inReplyTo":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","subject":"[PATCH v6 1/4] patch-ids: make commit_patch_id() a public helper function","fromName":"Xiaolong Ye","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-26T07:51:21Z","receivedAt":"2016-04-26T07:51:21Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"Make commit_patch_id() available to other builtins.\n\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n patch-ids.c | 2 +-\n patch-ids.h | 2 ++\n 2 files changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/patch-ids.c b/patch-ids.c\nindex b7b3e5a..a4d0016 100644\n--- a/patch-ids.c\n+++ b/patch-ids.c\n@@ -4,7 +4,7 @@\n #include \"sha1-lookup.h\"\n #include \"patch-ids.h\"\n \n-static int commit_patch_id(struct commit *commit, struct diff_options *options,\n+int commit_patch_id(struct commit *commit, struct diff_options *options,\n \t\t    unsigned char *sha1)\n {\n \tif (commit->parents)\ndiff --git a/patch-ids.h b/patch-ids.h\nindex c8c7ca1..eeb56b3 100644\n--- a/patch-ids.h\n+++ b/patch-ids.h\n@@ -13,6 +13,8 @@ struct patch_ids {\n \tstruct patch_id_bucket *patches;\n };\n \n+int commit_patch_id(struct commit *commit, struct diff_options *options,\n+\t\t    unsigned char *sha1);\n int init_patch_ids(struct patch_ids *);\n int free_patch_ids(struct patch_ids *);\n struct patch_id *add_commit_patch_id(struct commit *, struct patch_ids *);\n-- \n2.8.1.343.gda643e5\n"},{"id":"284517","messageId":"1461657084-9223-3-git-send-email-xiaolong.ye@intel.com","threadId":"42147","inReplyTo":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","subject":"[PATCH v6 2/4] format-patch: add '--base' option to record base tree info","fromName":"Xiaolong Ye","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-26T07:51:22Z","receivedAt":"2016-04-26T07:51:22Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"Maintainers or third party testers may want to know the exact base tree\nthe patch series applies to. Teach git format-patch a '--base' option\nto record the base tree info and append it at the end of the first\nmessage (either the cover letter or the first patch in the series).\n\nThe base tree info consists of the \"base commit\", which is a well-known\ncommit that is part of the stable part of the project history everybody\nelse works off of, and zero or more \"prerequisite patches\", which are\nwell-known patches in flight that is not yet part of the \"base commit\"\nthat need to be applied on top of \"base commit\" in topological order\nbefore the patches can be applied.\n\nThe \"base commit\" is shown as \"base-commit: \" followed by the 40-hex of\nthe commit object name.  A \"prerequisite patch\" is shown as\n\"prerequisite-patch-id: \" followed by the 40-hex \"patch id\", which can\nbe obtained by passing the patch through the \"git patch-id --stable\"\ncommand.\n\nImagine that on top of the public commit P, you applied well-known\npatches X, Y and Z from somebody else, and then built your three-patch\nseries A, B, C, the history would be like:\n\n---P---X---Y---Z---A---B---C\n\nWith \"git format-patch --base=P -3 C\" (or variants thereof, e.g. with\n\"--cover-letter\" of using \"Z..C\" instead of \"-3 C\" to specify the\nrange), the base tree information block is shown at the end of the\nfirst message the command outputs (either the first patch, or the\ncover letter), like this:\n\nbase-commit: P\nprerequisite-patch-id: X\nprerequisite-patch-id: Y\nprerequisite-patch-id: Z\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Wu Fengguang <fengguang.wu@intel.com>\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n Documentation/git-format-patch.txt |  54 ++++++++++++++\n builtin/log.c                      | 139 +++++++++++++++++++++++++++++++++++++\n t/t4014-format-patch.sh            |  47 +++++++++++++\n 3 files changed, 240 insertions(+)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 6821441..1d790f1 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -265,6 +265,11 @@ you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.\n   Output an all-zero hash in each patch's From header instead\n   of the hash of the commit.\n \n+--base=<commit>::\n+\tRecord the base tree information to identify the state the\n+\tpatch series applies to.  See the BASE TREE INFORMATION section\n+\tbelow for details.\n+\n --root::\n \tTreat the revision argument as a <revision range>, even if it\n \tis just a single commit (that would normally be treated as a\n@@ -520,6 +525,55 @@ This should help you to submit patches inline using KMail.\n 5. Back in the compose window: add whatever other text you wish to the\n    message, complete the addressing and subject fields, and press send.\n \n+BASE TREE INFORMATION\n+---------------------\n+\n+The base tree information block is used for maintainers or third party\n+testers to know the exact state the patch series applies to. It consists\n+of the 'base commit', which is a well-known commit that is part of the\n+stable part of the project history everybody else works off of, and zero\n+or more 'prerequisite patches', which are well-known patches in flight\n+that is not yet part of the 'base commit' that need to be applied on top\n+of 'base commit' in topological order before the patches can be applied.\n+\n+The 'base commit' is shown as \"base-commit: \" followed by the 40-hex of\n+the commit object name.  A 'prerequisite patch' is shown as\n+\"prerequisite-patch-id: \" followed by the 40-hex 'patch id', which can\n+be obtained by passing the patch through the `git patch-id --stable`\n+command.\n+\n+Imagine that on top of the public commit P, you applied well-known\n+patches X, Y and Z from somebody else, and then built your three-patch\n+series A, B, C, the history would be like:\n+\n+................................................\n+---P---X---Y---Z---A---B---C\n+................................................\n+\n+With `git format-patch --base=P -3 C` (or variants thereof, e.g. with\n+`--cover-letter` of using `Z..C` instead of `-3 C` to specify the\n+range), the base tree information block is shown at the end of the\n+first message the command outputs (either the first patch, or the\n+cover letter), like this:\n+\n+------------\n+base-commit: P\n+prerequisite-patch-id: X\n+prerequisite-patch-id: Y\n+prerequisite-patch-id: Z\n+------------\n+\n+For non-linear topology, such as\n+\n+................................................\n+---P---X---A---M---C\n+    \\         /\n+     Y---Z---B\n+................................................\n+\n+You can also use `git format-patch --base=P -3 C` to generate patches\n+for A, B and C, and the identifiers for P, X, Y, Z are appended at the\n+end of the first message.\n \n EXAMPLES\n --------\ndiff --git a/builtin/log.c b/builtin/log.c\nindex dff3fbb..ee332ab 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1191,6 +1191,131 @@ static int from_callback(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n+struct base_tree_info {\n+\tstruct object_id base_commit;\n+\tint nr_patch_id, alloc_patch_id;\n+\tstruct object_id *patch_id;\n+};\n+\n+static struct commit *get_base_commit(const char *base_commit,\n+\t\t\t\t      struct commit **list,\n+\t\t\t\t      int total)\n+{\n+\tstruct commit *base = NULL;\n+\tstruct commit **rev;\n+\tint i = 0, rev_nr = 0;\n+\n+\tbase = lookup_commit_reference_by_name(base_commit);\n+\tif (!base)\n+\t\tdie(_(\"Unknown commit %s\"), base_commit);\n+\n+\tALLOC_ARRAY(rev, total);\n+\tfor (i = 0; i < total; i++)\n+\t\trev[i] = list[i];\n+\n+\trev_nr = total;\n+\t/*\n+\t * Get merge base through pair-wise computations\n+\t * and store it in rev[0].\n+\t */\n+\twhile (rev_nr > 1) {\n+\t\tfor (i = 0; i < rev_nr / 2; i++) {\n+\t\t\tstruct commit_list *merge_base;\n+\t\t\tmerge_base = get_merge_bases(rev[2 * i], rev[2 * i + 1]);\n+\t\t\tif (!merge_base || merge_base->next)\n+\t\t\t\tdie(_(\"Failed to find exact merge base\"));\n+\n+\t\t\trev[i] = merge_base->item;\n+\t\t}\n+\n+\t\tif (rev_nr % 2)\n+\t\t\trev[i] = rev[2 * i];\n+\t\trev_nr = (rev_nr + 1) / 2;\n+\t}\n+\n+\tif (!in_merge_bases(base, rev[0]))\n+\t\tdie(_(\"base commit should be the ancestor of revision list\"));\n+\n+\tfor (i = 0; i < total; i++) {\n+\t\tif (base == list[i])\n+\t\t\tdie(_(\"base commit shouldn't be in revision list\"));\n+\t}\n+\n+\tfree(rev);\n+\treturn base;\n+}\n+\n+static void prepare_bases(struct base_tree_info *bases,\n+\t\t\t  struct commit *base,\n+\t\t\t  struct commit **list,\n+\t\t\t  int total)\n+{\n+\tstruct commit *commit;\n+\tstruct rev_info revs;\n+\tstruct diff_options diffopt;\n+\tint i;\n+\n+\tif (!base)\n+\t\treturn;\n+\n+\tdiff_setup(&diffopt);\n+\tDIFF_OPT_SET(&diffopt, RECURSIVE);\n+\tdiff_setup_done(&diffopt);\n+\n+\toidcpy(&bases->base_commit, &base->object.oid);\n+\n+\tinit_revisions(&revs, NULL);\n+\trevs.max_parents = 1;\n+\trevs.topo_order = 1;\n+\tfor (i = 0; i < total; i++) {\n+\t\tlist[i]->object.flags &= ~UNINTERESTING;\n+\t\tadd_pending_object(&revs, &list[i]->object, \"rev_list\");\n+\t\tlist[i]->util = (void *)1;\n+\t}\n+\tbase->object.flags |= UNINTERESTING;\n+\tadd_pending_object(&revs, &base->object, \"base\");\n+\n+\tif (prepare_revision_walk(&revs))\n+\t\tdie(_(\"revision walk setup failed\"));\n+\t/*\n+\t * Traverse the commits list, get prerequisite patch ids\n+\t * and stuff them in bases structure.\n+\t */\n+\twhile ((commit = get_revision(&revs)) != NULL) {\n+\t\tunsigned char sha1[20];\n+\t\tstruct object_id *patch_id;\n+\t\tif (commit->util)\n+\t\t\tcontinue;\n+\t\tif (commit_patch_id(commit, &diffopt, sha1))\n+\t\t\tdie(_(\"cannot get patch id\"));\n+\t\tALLOC_GROW(bases->patch_id, bases->nr_patch_id + 1, bases->alloc_patch_id);\n+\t\tpatch_id = bases->patch_id + bases->nr_patch_id;\n+\t\thashcpy(patch_id->hash, sha1);\n+\t\tbases->nr_patch_id++;\n+\t}\n+}\n+\n+static void print_bases(struct base_tree_info *bases)\n+{\n+\tint i;\n+\n+\t/* Only do this once, either for the cover or for the first one */\n+\tif (is_null_oid(&bases->base_commit))\n+\t\treturn;\n+\n+\t/* Show the base commit */\n+\tprintf(\"base-commit: %s\\n\", oid_to_hex(&bases->base_commit));\n+\n+\t/* Show the prerequisite patches */\n+\tfor (i = bases->nr_patch_id - 1; i >= 0; i--)\n+\t\tprintf(\"prerequisite-patch-id: %s\\n\", oid_to_hex(&bases->patch_id[i]));\n+\n+\tfree(bases->patch_id);\n+\tbases->nr_patch_id = 0;\n+\tbases->alloc_patch_id = 0;\n+\toidclr(&bases->base_commit);\n+}\n+\n int cmd_format_patch(int argc, const char **argv, const char *prefix)\n {\n \tstruct commit *commit;\n@@ -1215,6 +1340,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \tint reroll_count = -1;\n \tchar *branch_name = NULL;\n \tchar *from = NULL;\n+\tchar *base_commit = NULL;\n+\tstruct base_tree_info bases;\n+\n \tconst struct option builtin_format_patch_options[] = {\n \t\t{ OPTION_CALLBACK, 'n', \"numbered\", &numbered, NULL,\n \t\t\t    N_(\"use [PATCH n/m] even with a single patch\"),\n@@ -1277,6 +1405,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t    PARSE_OPT_OPTARG, thread_callback },\n \t\tOPT_STRING(0, \"signature\", &signature, N_(\"signature\"),\n \t\t\t    N_(\"add a signature\")),\n+\t\tOPT_STRING(0, \"base\", &base_commit, N_(\"base-commit\"),\n+\t\t\t   N_(\"add prerequisite tree info to the patch series\")),\n \t\tOPT_FILENAME(0, \"signature-file\", &signature_file,\n \t\t\t\tN_(\"add a signature from a file\")),\n \t\tOPT__QUIET(&quiet, N_(\"don't print the patch filenames\")),\n@@ -1514,6 +1644,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\tsignature = strbuf_detach(&buf, NULL);\n \t}\n \n+\tmemset(&bases, 0, sizeof(bases));\n+\tif (base_commit) {\n+\t\tstruct commit *base = get_base_commit(base_commit, list, nr);\n+\t\treset_revision_walk();\n+\t\tprepare_bases(&bases, base, list, nr);\n+\t}\n+\n \tif (in_reply_to || thread || cover_letter)\n \t\trev.ref_message_ids = xcalloc(1, sizeof(struct string_list));\n \tif (in_reply_to) {\n@@ -1527,6 +1664,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\tgen_message_id(&rev, \"cover\");\n \t\tmake_cover_letter(&rev, use_stdout,\n \t\t\t\t  origin, nr, list, branch_name, quiet);\n+\t\tprint_bases(&bases);\n \t\ttotal++;\n \t\tstart_number--;\n \t}\n@@ -1592,6 +1730,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t\t\t\t       rev.mime_boundary);\n \t\t\telse\n \t\t\t\tprint_signature();\n+\t\t\tprint_bases(&bases);\n \t\t}\n \t\tif (!use_stdout)\n \t\t\tfclose(stdout);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex eed2981..5dcf24f 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1460,4 +1460,51 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '\n \ttest_path_is_dir patchset\n '\n \n+test_expect_success 'format-patch --base' '\n+\tgit checkout side &&\n+\tgit format-patch --stdout --base=HEAD~3 -1 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\tgrep \"^prerequisite-patch-id:\" patch >>actual &&\n+\techo \"base-commit: $(git rev-parse HEAD~3)\" >expected &&\n+\techo \"prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk \"{print \\$1}\")\" >>expected &&\n+\techo \"prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk \"{print \\$1}\")\" >>expected &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'format-patch --base errors out when base commit is in revision list' '\n+\ttest_must_fail git format-patch --base=HEAD -2 &&\n+\ttest_must_fail git format-patch --base=HEAD~1 -2 &&\n+\tgit format-patch --stdout --base=HEAD~2 -2 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\techo \"base-commit: $(git rev-parse HEAD~2)\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'format-patch --base errors out when base commit is not ancestor of revision list' '\n+\t# For history as below:\n+\t#\n+\t#    ---Q---P---Z---Y---*---X\n+\t#\t \\             /\n+\t#\t  ------------W\n+\t#\n+\t# If \"format-patch Z..X\" is given, P and Z can not be specified as the base commit\n+\tgit checkout -b topic1 master &&\n+\tgit rev-parse HEAD >commit-id-base &&\n+\ttest_commit P &&\n+\tgit rev-parse HEAD >commit-id-P &&\n+\ttest_commit Z &&\n+\tgit rev-parse HEAD >commit-id-Z &&\n+\ttest_commit Y &&\n+\tgit checkout -b topic2 master &&\n+\ttest_commit W &&\n+\tgit merge topic1 &&\n+\ttest_commit X &&\n+\ttest_must_fail git format-patch --base=$(cat commit-id-P) -3 &&\n+\ttest_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&\n+\tgit format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\techo \"base-commit: $(cat commit-id-base)\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.8.1.343.gda643e5\n"},{"id":"284518","messageId":"1461657084-9223-4-git-send-email-xiaolong.ye@intel.com","threadId":"42147","inReplyTo":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","subject":"[PATCH v6 3/4] format-patch: introduce --base=auto option","fromName":"Xiaolong Ye","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-26T07:51:23Z","receivedAt":"2016-04-26T07:51:23Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"Introduce --base=auto to record the base commit info automatically, the\nbase_commit will be the merge base of tip commit of the upstream branch\nand revision-range specified in cmdline.\n\nHelped-by: Junio C Hamano <gitster@pobox.com>\nHelped-by: Wu Fengguang <fengguang.wu@intel.com>\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n Documentation/git-format-patch.txt |  6 ++++++\n builtin/log.c                      | 30 ++++++++++++++++++++++++++---\n t/t4014-format-patch.sh            | 39 ++++++++++++++++++++++++++++++++++++++\n 3 files changed, 72 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt\nindex 1d790f1..bdeecd5 100644\n--- a/Documentation/git-format-patch.txt\n+++ b/Documentation/git-format-patch.txt\n@@ -575,6 +575,12 @@ You can also use `git format-patch --base=P -3 C` to generate patches\n for A, B and C, and the identifiers for P, X, Y, Z are appended at the\n end of the first message.\n \n+If set `--base=auto` in cmdline, it will track base commit automatically,\n+the base commit will be the merge base of tip commit of the remote-tracking\n+branch and revision-range specified in cmdline.\n+For a local branch, you need to track a remote branch by `git branch\n+--set-upstream-to` before using this option.\n+\n EXAMPLES\n --------\n \ndiff --git a/builtin/log.c b/builtin/log.c\nindex ee332ab..db27135 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -1205,9 +1205,33 @@ static struct commit *get_base_commit(const char *base_commit,\n \tstruct commit **rev;\n \tint i = 0, rev_nr = 0;\n \n-\tbase = lookup_commit_reference_by_name(base_commit);\n-\tif (!base)\n-\t\tdie(_(\"Unknown commit %s\"), base_commit);\n+\tif (!strcmp(base_commit, \"auto\")) {\n+\t\tstruct branch *curr_branch = branch_get(NULL);\n+\t\tconst char *upstream = branch_get_upstream(curr_branch, NULL);\n+\t\tif (upstream) {\n+\t\t\tstruct commit_list *base_list;\n+\t\t\tstruct commit *commit;\n+\t\t\tunsigned char sha1[20];\n+\n+\t\t\tif (get_sha1(upstream, sha1))\n+\t\t\t\tdie(_(\"Failed to resolve '%s' as a valid ref.\"), upstream);\n+\t\t\tcommit = lookup_commit_or_die(sha1, \"upstream base\");\n+\t\t\tbase_list = get_merge_bases_many(commit, total, list);\n+\t\t\t/* There should be one and only one merge base. */\n+\t\t\tif (!base_list || base_list->next)\n+\t\t\t\tdie(_(\"Could not find exact merge base.\"));\n+\t\t\tbase = base_list->item;\n+\t\t\tfree_commit_list(base_list);\n+\t\t} else {\n+\t\t\tdie(_(\"Failed to get upstream, if you want to record base commit automatically,\\n\"\n+\t\t\t      \"please use git branch --set-upstream-to to track a remote branch.\\n\"\n+\t\t\t      \"Or you could specify base commit by --base=<base-commit-id> manually.\"));\n+\t\t}\n+\t} else {\n+\t\tbase = lookup_commit_reference_by_name(base_commit);\n+\t\tif (!base)\n+\t\t\tdie(_(\"Unknown commit %s\"), base_commit);\n+\t}\n \n \tALLOC_ARRAY(rev, total);\n \tfor (i = 0; i < total; i++)\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 5dcf24f..8102158 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1507,4 +1507,43 @@ test_expect_success 'format-patch --base errors out when base commit is not ance\n \ttest_cmp expected actual\n '\n \n+test_expect_success 'format-patch --base=auto' '\n+\tgit checkout -b upstream master &&\n+\tgit checkout -b local upstream &&\n+\tgit branch --set-upstream-to=upstream &&\n+\ttest_commit N1 &&\n+\ttest_commit N2 &&\n+\tgit format-patch --stdout --base=auto -2 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\techo \"base-commit: $(git rev-parse upstream)\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'format-patch errors out when history involves criss-cross' '\n+\t# setup criss-cross history\n+\t#\n+\t#   B---M1---D\n+\t#  / \\ /\n+\t# A   X\n+\t#  \\ / \\\n+\t#   C---M2---E\n+\t#\n+\tgit checkout master &&\n+\ttest_commit A &&\n+\tgit checkout -b xb master &&\n+\ttest_commit B &&\n+\tgit checkout -b xc master &&\n+\ttest_commit C &&\n+\tgit checkout -b xbc xb -- &&\n+\tgit merge xc &&\n+\tgit checkout -b xcb xc -- &&\n+\tgit branch --set-upstream-to=xbc &&\n+\tgit merge xb &&\n+\tgit checkout xbc &&\n+\ttest_commit D &&\n+\tgit checkout xcb &&\n+\ttest_commit E &&\n+\ttest_must_fail \tgit format-patch --base=auto -1\n+'\n+\n test_done\n-- \n2.8.1.343.gda643e5\n"},{"id":"284519","messageId":"1461657084-9223-5-git-send-email-xiaolong.ye@intel.com","threadId":"42147","inReplyTo":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","subject":"[PATCH v6 4/4] format-patch: introduce format.useAutoBase configuration","fromName":"Xiaolong Ye","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-26T07:51:24Z","receivedAt":"2016-04-26T07:51:24Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"This allows to record the base commit automatically, it is equivalent\nto set --base=auto in cmdline.\n\nThe format.useAutoBase has lower priority than command line option,\nso if user set format.useAutoBase and pass the command line option in\nthe meantime, base_commit will be the one passed to command line\noption.\n\nSigned-off-by: Xiaolong Ye <xiaolong.ye@intel.com>\n---\n Documentation/config.txt |  5 +++++\n builtin/log.c            | 17 +++++++++++------\n t/t4014-format-patch.sh  | 19 +++++++++++++++++++\n 3 files changed, 35 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 42d2b50..1fe2a85 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1259,6 +1259,11 @@ format.outputDirectory::\n \tSet a custom directory to store the resulting files instead of the\n \tcurrent working directory.\n \n+format.useAutoBase::\n+\tA boolean value which lets you enable the `--base=auto` option of\n+\tformat-patch by default.\n+\n+\n filter.<driver>.clean::\n \tThe command which is used to convert the content of a worktree\n \tfile to a blob upon checkin.  See linkgit:gitattributes[5] for\ndiff --git a/builtin/log.c b/builtin/log.c\nindex db27135..099f4f7 100644\n--- a/builtin/log.c\n+++ b/builtin/log.c\n@@ -702,6 +702,7 @@ static void add_header(const char *value)\n #define THREAD_DEEP 2\n static int thread;\n static int do_signoff;\n+static int base_auto;\n static const char *signature = git_version_string;\n static const char *signature_file;\n static int config_cover_letter;\n@@ -786,6 +787,10 @@ static int git_format_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"format.outputdirectory\"))\n \t\treturn git_config_string(&config_output_directory, var, value);\n+\tif (!strcmp(var, \"format.useautobase\")) {\n+\t\tbase_auto = git_config_bool(var, value);\n+\t\treturn 0;\n+\t}\n \n \treturn git_log_config(var, value, cb);\n }\n@@ -1205,7 +1210,11 @@ static struct commit *get_base_commit(const char *base_commit,\n \tstruct commit **rev;\n \tint i = 0, rev_nr = 0;\n \n-\tif (!strcmp(base_commit, \"auto\")) {\n+\tif (base_commit && strcmp(base_commit, \"auto\")) {\n+\t\tbase = lookup_commit_reference_by_name(base_commit);\n+\t\tif (!base)\n+\t\t\tdie(_(\"Unknown commit %s\"), base_commit);\n+\t} else if ((base_commit && !strcmp(base_commit, \"auto\")) || base_auto) {\n \t\tstruct branch *curr_branch = branch_get(NULL);\n \t\tconst char *upstream = branch_get_upstream(curr_branch, NULL);\n \t\tif (upstream) {\n@@ -1227,10 +1236,6 @@ static struct commit *get_base_commit(const char *base_commit,\n \t\t\t      \"please use git branch --set-upstream-to to track a remote branch.\\n\"\n \t\t\t      \"Or you could specify base commit by --base=<base-commit-id> manually.\"));\n \t\t}\n-\t} else {\n-\t\tbase = lookup_commit_reference_by_name(base_commit);\n-\t\tif (!base)\n-\t\t\tdie(_(\"Unknown commit %s\"), base_commit);\n \t}\n \n \tALLOC_ARRAY(rev, total);\n@@ -1669,7 +1674,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)\n \t}\n \n \tmemset(&bases, 0, sizeof(bases));\n-\tif (base_commit) {\n+\tif (base_commit || base_auto) {\n \t\tstruct commit *base = get_base_commit(base_commit, list, nr);\n \t\treset_revision_walk();\n \t\tprepare_bases(&bases, base, list, nr);\ndiff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh\nindex 8102158..8049cad 100755\n--- a/t/t4014-format-patch.sh\n+++ b/t/t4014-format-patch.sh\n@@ -1546,4 +1546,23 @@ test_expect_success 'format-patch errors out when history involves criss-cross'\n \ttest_must_fail \tgit format-patch --base=auto -1\n '\n \n+test_expect_success 'format-patch format.useAutoBaseoption' '\n+\ttest_when_finished \"git config --unset format.useAutoBase\" &&\n+\tgit checkout local &&\n+\tgit config format.useAutoBase true &&\n+\tgit format-patch --stdout -1 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\techo \"base-commit: $(git rev-parse upstream)\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n+test_expect_success 'format-patch --base overrides format.useAutoBase' '\n+\ttest_when_finished \"git config --unset format.useAutoBase\" &&\n+\tgit config format.useAutoBase true &&\n+\tgit format-patch --stdout --base=HEAD~1 -1 >patch &&\n+\tgrep \"^base-commit:\" patch >actual &&\n+\techo \"base-commit: $(git rev-parse HEAD~1)\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n test_done\n-- \n2.8.1.343.gda643e5\n"},{"id":"284542","messageId":"CAGZ79kbNzmP2Zwf-99R1jxteNAqV-4QatU0mGhQ9hyapvnAf4g@mail.gmail.com","threadId":"42147","inReplyTo":"1461657084-9223-5-git-send-email-xiaolong.ye@intel.com","subject":"Re: [PATCH v6 4/4] format-patch: introduce format.useAutoBase configuration","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-26T17:11:13Z","receivedAt":"2016-04-26T17:11:13Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"> +format.useAutoBase::\n> +       A boolean value which lets you enable the `--base=auto` option of\n> +       format-patch by default.\n> +\n> +\n\nIn case you resend, please use just one empty line here?\n(No need to resend because of this alone)\n"},{"id":"284545","messageId":"CAGZ79kajpAtbHaKLaLHN5+qUOvBofFs-q-vUYWua49GWK7FO9Q@mail.gmail.com","threadId":"42147","inReplyTo":"1461657084-9223-1-git-send-email-xiaolong.ye@intel.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-26T17:21:25Z","receivedAt":"2016-04-26T17:21:25Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Apr 26, 2016 at 12:51 AM, Xiaolong Ye <xiaolong.ye@intel.com> wrote:\n> Thanks for Junio's reviews and suggestions.\n>\n> This version contains the following changes since v5:\n>\n>  - Fix a decl-after-statement in patch 3/4.\n>\n>  - Improve testcases to cover more scenarios and make them more portable and\n>    readable.\n>\n> Thanks,\n> Xiaolong\n>\n\nThanks for this feature!\n\nI am playing around with this series, and here comes a feature request:\nI have a local branch with no upstream set. My usual workflow is like this\n\n    git checkout origin/master\n    # toy around, do stuff\n    git checkout -b new-shiny-feature\n    git format-patch origin-master..\n\nNow I have set the format.useautobase option and then the `git format-patch`\nfails with\n\n    fatal: Failed to get upstream, if you want to record base commit\nautomatically,\n    please use git branch --set-upstream-to to track a remote branch.\n    Or you could specify base commit by --base=<base-commit-id> manually.\n\nbut as I indicated I want patches from origin/master onwards,\nCould we make use of that information? To record the base in my workflow\ncurrently I need to do:\n\n    git format-patch origin/master.. --base=origin/master\n\nwhich seems redundant to me.\n(I may be holding it wrong though? Should I try to set upstream\nbranches for my local branches? This seems weird to me as I cannot\npush/change the upstream branches directly, as Junio owns the branches)\n\nThanks,\nStefan\n"},{"id":"284556","messageId":"xmqqlh40gs9o.fsf@gitster.mtv.corp.google.com","threadId":"42147","inReplyTo":"CAGZ79kajpAtbHaKLaLHN5+qUOvBofFs-q-vUYWua49GWK7FO9Q@mail.gmail.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-26T18:05:23Z","receivedAt":"2016-04-26T18:05:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>     git checkout origin/master\n>     # toy around, do stuff\n>     git checkout -b new-shiny-feature\n>     git format-patch origin-master..\n>\n> Now I have set the format.useautobase option and then the `git format-patch`\n> fails with\n>\n>     fatal: Failed to get upstream, if you want to record base commit\n> automatically,\n>     please use git branch --set-upstream-to to track a remote branch.\n>     Or you could specify base commit by --base=<base-commit-id> manually.\n>\n> but as I indicated I want patches from origin/master onwards,\n> Could we make use of that information?\n\nAs you indicated where other than in this e-mail?  \n\nI think the way for you to indicate that desire expected by this\nseries is to use \"git branch\" to set upstream of new-shiny-feature\nbranch to origin/master.  Shouldn't that work, or is that too much\nwork?\n"},{"id":"284563","messageId":"CAGZ79kZg3OpR8k45=q1m-g=t+aGGs8VDYBrBYaBU_DbfuuoBig@mail.gmail.com","threadId":"42147","inReplyTo":"xmqqlh40gs9o.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-26T18:20:58Z","receivedAt":"2016-04-26T18:20:58Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Apr 26, 2016 at 11:05 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>>     git checkout origin/master\n>>     # toy around, do stuff\n>>     git checkout -b new-shiny-feature\n>>     git format-patch origin-master..\n>>\n>> Now I have set the format.useautobase option and then the `git format-patch`\n>> fails with\n>>\n>>     fatal: Failed to get upstream, if you want to record base commit\n>> automatically,\n>>     please use git branch --set-upstream-to to track a remote branch.\n>>     Or you could specify base commit by --base=<base-commit-id> manually.\n>>\n>> but as I indicated I want patches from origin/master onwards,\n>> Could we make use of that information?\n>\n> As you indicated where other than in this e-mail?\n>\n> I think the way for you to indicate that desire expected by this\n> series is to use \"git branch\" to set upstream of new-shiny-feature\n> branch to origin/master.  Shouldn't that work, or is that too much\n> work?\n\nI can totally do that for longer series which require some back and forth.\n\nBut one-offs, such as typo fixes or other small things[1], for which I do\neven have a local branch (i.e. checkout origin/master && fix &&\ncommit && send-email) this is another step that potentially bothers me.\nMaybe I'll get used to it.\n\n>From a UI perspective it seems logical to also check if the base\ncan be obtained from the patch range specifier. the message of\npatch 2 focuses on the advantages for the maintainer and 3rd party\npeople. So I was just testing it as an individual contributor to ensure\nit can be used easily. (People only use this once the benefits outweigh\nthe disadvantages. And as we do not have any advantage of it in Git,\nthe negatives need to be kept low?)\n\nThanks,\nStefan\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/292634\n"},{"id":"284566","messageId":"xmqqd1pcgr3s.fsf@gitster.mtv.corp.google.com","threadId":"42147","inReplyTo":"CAGZ79kZg3OpR8k45=q1m-g=t+aGGs8VDYBrBYaBU_DbfuuoBig@mail.gmail.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-26T18:30:31Z","receivedAt":"2016-04-26T18:30:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n> I can totally do that for longer series which require some back and forth.\n>\n> But one-offs, such as typo fixes or other small things[1], for which I do\n> even have a local branch (i.e. checkout origin/master && fix &&\n> commit && send-email) this is another step that potentially bothers me.\n\nSo from where are you proposing Git to grab that information if you\ndo not tell it?  \"If the HEAD is detached, assume that the base is\nwhere it was detached from\" or something?\n\n> From a UI perspective it seems logical to also check if the base\n> can be obtained from the patch range specifier.\n\nIf you are doing \"format-patch master..my-branch\", what do you\npropose to set your base to?  master@{u}, perhaps?\n"},{"id":"284568","messageId":"CAGZ79kZNV+g3_Rmpynh-WQVc3dW6nuNDsTM=gTxNuJnr3V3Azg@mail.gmail.com","threadId":"42147","inReplyTo":"xmqqd1pcgr3s.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-26T18:43:15Z","receivedAt":"2016-04-26T18:43:15Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Apr 26, 2016 at 11:30 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Stefan Beller <sbeller@google.com> writes:\n>\n>> I can totally do that for longer series which require some back and forth.\n>>\n>> But one-offs, such as typo fixes or other small things[1], for which I do\n>> even have a local branch (i.e. checkout origin/master && fix &&\n>> commit && send-email) this is another step that potentially bothers me.\n>\n> So from where are you proposing Git to grab that information if you\n> do not tell it?  \"If the HEAD is detached, assume that the base is\n> where it was detached from\" or something?\n\nThat would also work for me. In my first mail I was proposing to take\nthe information from the format-patch argument, such that a one off fix\nwould be:\n\n    (1) git checkout origin/master\n    (2) EDIT\n    (3) git commit -a -m \"fix\"\n    (4) git format-patch origin/master..  # <- This is the information.\n\nHowever you read it as taking the information from the first line,\nwhich is also fine with me, as then the (4) can become\n\n    (4a) git format-patch HEAD^\n\nAnother thought:\n\n  Most workflows do not have different remotes per branch, e.g.\n  when `master` maps to  `origin/master` as its upstream it is likely that\n  `topic-foo` maps to its equivalent at `origin/..` as well.\n\n  Branches come and go in a topic based workflow, so configuring them\n  for each new branch is cumbersome, so let's have a default `remote` for\n  repository.\n\nIf we have a default remote per repository, the base finding algorithm\nin format-patch could check if the base(s) of the patch series is a head\nin one of the default remote branches, i.e. check all origin/* branches for\na match?\n\n\n>\n>> From a UI perspective it seems logical to also check if the base\n>> can be obtained from the patch range specifier.\n>\n> If you are doing \"format-patch master..my-branch\", what do you\n> propose to set your base to?  master@{u}, perhaps?\n\nYes. (I usually use that command with |s|master|origin/master|, so the\nargument is the upstream already. A local master branch does not exist for me.)\n\n>\n"},{"id":"284570","messageId":"xmqq4maogpsw.fsf@gitster.mtv.corp.google.com","threadId":"42147","inReplyTo":"CAGZ79kZNV+g3_Rmpynh-WQVc3dW6nuNDsTM=gTxNuJnr3V3Azg@mail.gmail.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-26T18:58:39Z","receivedAt":"2016-04-26T18:58:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stefan Beller <sbeller@google.com> writes:\n\n>> So from where are you proposing Git to grab that information if you\n>> do not tell it?  \"If the HEAD is detached, assume that the base is\n>> where it was detached from\" or something?\n>\n> That would also work for me. In my first mail I was proposing to take\n> the information from the format-patch argument, such that a one off fix\n> would be:\n>\n>     (1) git checkout origin/master\n>     (2) EDIT\n>     (3) git commit -a -m \"fix\"\n>     (4) git format-patch origin/master..  # <- This is the information.\n>\n> However you read it as taking the information from the first line,\n> which is also fine with me, as then the (4) can become\n>\n>     (4a) git format-patch HEAD^\n\nEither would work, but reading from (4) feels a lot less black magic\nto me.\n\n>> If you are doing \"format-patch master..my-branch\", what do you\n>> propose to set your base to?  master@{u}, perhaps?\n>\n> Yes. (I usually use that command with |s|master|origin/master|, so the\n> argument is the upstream already. A local master branch does not exist for me.)\n\nLet's hear from folks at Intel ;-) Both of the above sounds like\nsensible enhancements to me.\n"},{"id":"284618","messageId":"CAGZ79kbTqW82Tj3KvXwYYhSWxuGvaGeYoAZrJkkM6FR4rhwC+Q@mail.gmail.com","threadId":"42147","inReplyTo":"CAGZ79kZg3OpR8k45=q1m-g=t+aGGs8VDYBrBYaBU_DbfuuoBig@mail.gmail.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-26T22:56:36Z","receivedAt":"2016-04-26T22:56:36Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Apr 26, 2016 at 11:20 AM, Stefan Beller <sbeller@google.com> wrote:\n> On Tue, Apr 26, 2016 at 11:05 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>> I think the way for you to indicate that desire expected by this\n>> series is to use \"git branch\" to set upstream of new-shiny-feature\n>> branch to origin/master.  Shouldn't that work, or is that too much\n>> work?\n>\n> I can totally do that for longer series which require some back and forth.\n>\n\nSo the submodule groups series is an example with some back and forth,\nso I'll try to take that workflow with setting an upstream there for now.\nAs the groups stuff is based on origin/sb/submodule-init I set that as the\nremote upstream branch. Upon checking that out I get:\n\n    Switched to branch 'submodule-groups'\n    Your branch is ahead of 'origin/sb/submodule-init' by 15 commits.\n      (use \"git push\" to publish your local commits)\n\nThe first 2 lines are correct, the third however is not correct. (I cannot push\nto your repository, but only email patches)\n\nSo I wonder if\n * I configured the wrong upstream branch\n * the upstream branch concept is extended to more/other use cases by the\n   format.useAutoBase option. (In an email based workflow you would use the\n   a remote branch to a remote, which is not owned by yourself, so the push\n   advice is invalid from now on and we patch that message)\n * using an explicit upstream branch is the wrong approach here and the\n   base should be implicit, i.e. Take the base sha1 and see if there is\n   (one/any) remote branch matching that sha1.\n   If there is, use the sha1 just fine.\n\nThanks,\nStefan\n"},{"id":"284635","messageId":"20160427073350.GA30342@yexl-desktop","threadId":"42147","inReplyTo":"xmqq4maogpsw.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Ye Xiaolong","fromEmail":"xiaolong.ye@intel.com","sentAt":"2016-04-27T07:33:50Z","receivedAt":"2016-04-27T07:33:50Z","isPatch":true,"sender":{"key":"xiaolong.ye@intel.com","avatar":"https://avatars.githubusercontent.com/u/21098480?v=4"},"body":"On Tue, Apr 26, 2016 at 11:58:39AM -0700, Junio C Hamano wrote:\n>Stefan Beller <sbeller@google.com> writes:\n>\n>>> So from where are you proposing Git to grab that information if you\n>>> do not tell it?  \"If the HEAD is detached, assume that the base is\n>>> where it was detached from\" or something?\n>>\n>> That would also work for me. In my first mail I was proposing to take\n>> the information from the format-patch argument, such that a one off fix\n>> would be:\n>>\n>>     (1) git checkout origin/master\n>>     (2) EDIT\n>>     (3) git commit -a -m \"fix\"\n>>     (4) git format-patch origin/master..  # <- This is the information.\n>>\n>> However you read it as taking the information from the first line,\n>> which is also fine with me, as then the (4) can become\n>>\n>>     (4a) git format-patch HEAD^\n\nThanks for the suggestion, I think this feature would definitely save\neffort for end users and help to improve the usage rate of this \"--base\"\noption.\n\nIf I understand it correctly, we should try to parse the \"revision range\"\nspecified in the fomat-patch cmdline if format.useAutoBase is set and we\ncouldn't find the remote-tracking branch, if its pattern matches something\nlike \"<branchname>..<rev2>\", we will try to get base commit from it:\n\n  - If it is a remote branch, just set its head as base\n  - If it isn't, try to set branchname@{u} as base\n\nPlease correct me if I'm wrong.\n\n>\n>Either would work, but reading from (4) feels a lot less black magic\n>to me.\n>\n>>> If you are doing \"format-patch master..my-branch\", what do you\n>>> propose to set your base to?  master@{u}, perhaps?\n>>\n>> Yes. (I usually use that command with |s|master|origin/master|, so the\n>> argument is the upstream already. A local master branch does not exist for me.)\n>\n>Let's hear from folks at Intel ;-) Both of the above sounds like\n>sensible enhancements to me.\n\nShall I squash these enhancements in this series, or I need to make\nanother patch for them?\n\nThanks,\nXiaolong\n"},{"id":"284649","messageId":"xmqqr3dray9e.fsf@gitster.mtv.corp.google.com","threadId":"42147","inReplyTo":"20160427073350.GA30342@yexl-desktop","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-04-27T15:04:45Z","receivedAt":"2016-04-27T15:04:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ye Xiaolong <xiaolong.ye@intel.com> writes:\n\n> On Tue, Apr 26, 2016 at 11:58:39AM -0700, Junio C Hamano wrote:\n>\n>>Let's hear from folks at Intel ;-) Both of the above sounds like\n>>sensible enhancements to me.\n>\n> Shall I squash these enhancements in this series, or I need to make\n> another patch for them?\n\nThe update being discussed is not a \"oops, the series without this\nupdate is embarrassingly flawed\" fix, but rather \"the series is good\nenough to be used as-is, but here is to potentially make it even\nbetter\", I'd prefer to have it as a separate, follow-up patch that\napplies on top of what has been queued.  That way, if this turns out\nto be not so good idea, removing it alone while preserving what is\nalready there will be easier, and also others who will be studying\nthe code to further enhance the heuristics of base selection in the\nfuture will benefit.\n"},{"id":"284657","messageId":"CAGZ79kbvdTTLReVrrO8X0jTJn5kDn1n1cAS1Fo+-jWdGK5G1LQ@mail.gmail.com","threadId":"42147","inReplyTo":"xmqqr3dray9e.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH v6 0/4] Add --base option to git-format-patch to record base tree info","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2016-04-27T15:45:08Z","receivedAt":"2016-04-27T15:45:08Z","isPatch":true,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Wed, Apr 27, 2016 at 8:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Ye Xiaolong <xiaolong.ye@intel.com> writes:\n>\n>> On Tue, Apr 26, 2016 at 11:58:39AM -0700, Junio C Hamano wrote:\n>>\n>>>Let's hear from folks at Intel ;-) Both of the above sounds like\n>>>sensible enhancements to me.\n>>\n>> Shall I squash these enhancements in this series, or I need to make\n>> another patch for them?\n>\n> The update being discussed is not a \"oops, the series without this\n> update is embarrassingly flawed\" fix, but rather \"the series is good\n> enough to be used as-is, but here is to potentially make it even\n> better\", I'd prefer to have it as a separate, follow-up patch that\n> applies on top of what has been queued.  That way, if this turns out\n> to be not so good idea, removing it alone while preserving what is\n> already there will be easier, and also others who will be studying\n> the code to further enhance the heuristics of base selection in the\n> future will benefit.\n\nI agree. I was just suggesting going the extra mile to make it easier\nfor the user. :)\n"}]}