]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/deprecate-grafts'
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 May 2018 05:38:17 +0000 (14:38 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 May 2018 05:38:17 +0000 (14:38 +0900)
The functionality of "$GIT_DIR/info/grafts" has been superseded by
the "refs/replace/" mechanism for some time now, but the internal
code had support for it in many places, which has been cleaned up
in order to drop support of the "grafts" mechanism.

* js/deprecate-grafts:
  Remove obsolete script to convert grafts to replace refs
  technical/shallow: describe why shallow cannot use replace refs
  technical/shallow: stop referring to grafts
  filter-branch: stop suggesting to use grafts
  Deprecate support for .git/info/grafts
  Add a test for `git replace --convert-graft-file`
  replace: introduce --convert-graft-file
  replace: prepare create_graft() for converting graft files wholesale
  replace: "libify" create_graft() and callees
  replace: avoid using die() to indicate a bug
  commit: Let the callback of for_each_mergetag return on error
  argv_array: offer to split a string by whitespace

1  2 
advice.c
builtin/replace.c
commit.c
commit.h
log-tree.c

diff --cc advice.c
index 89fda1de55bfc80ba884ab45dd7a31087dea66df,4411704fd45a020a60535917905c8e70dd3d791a..370a56d0546bb3fc7aa4a62203c600e9a8af2d7a
+++ b/advice.c
@@@ -20,34 -19,8 +20,35 @@@ int advice_rm_hints = 1
  int advice_add_embedded_repo = 1;
  int advice_ignored_hook = 1;
  int advice_waiting_for_editor = 1;
+ int advice_graft_file_deprecated = 1;
  
 +static int advice_use_color = -1;
 +static char advice_colors[][COLOR_MAXLEN] = {
 +      GIT_COLOR_RESET,
 +      GIT_COLOR_YELLOW,       /* HINT */
 +};
 +
 +enum color_advice {
 +      ADVICE_COLOR_RESET = 0,
 +      ADVICE_COLOR_HINT = 1,
 +};
 +
 +static int parse_advise_color_slot(const char *slot)
 +{
 +      if (!strcasecmp(slot, "reset"))
 +              return ADVICE_COLOR_RESET;
 +      if (!strcasecmp(slot, "hint"))
 +              return ADVICE_COLOR_HINT;
 +      return -1;
 +}
 +
 +static const char *advise_get_color(enum color_advice ix)
 +{
 +      if (want_color_stderr(advice_use_color))
 +              return advice_colors[ix];
 +      return "";
 +}
 +
  static struct {
        const char *name;
        int *preference;
index 14e142d5a80044a6e9565db7fcb7b327387fd128,a87fca045be831c2e14b0c4977d48f205833bace..6da2411e14b9f94f309671e14124ef32d89ef528
@@@ -82,11 -80,11 +83,11 @@@ static int list_replace_refs(const cha
        else if (!strcmp(format, "long"))
                data.format = REPLACE_FORMAT_LONG;
        else
-               die("invalid replace format '%s'\n"
-                   "valid formats are 'short', 'medium' and 'long'\n",
-                   format);
+               return error("invalid replace format '%s'\n"
+                            "valid formats are 'short', 'medium' and 'long'\n",
+                            format);
  
 -      for_each_replace_ref(show_reference, (void *)&data);
 +      for_each_replace_ref(the_repository, show_reference, (void *)&data);
  
        return 0;
  }
@@@ -164,17 -163,22 +166,22 @@@ static int replace_object_oid(const cha
        struct strbuf ref = STRBUF_INIT;
        struct ref_transaction *transaction;
        struct strbuf err = STRBUF_INIT;
+       int res = 0;
  
 -      obj_type = oid_object_info(object, NULL);
 -      repl_type = oid_object_info(repl, NULL);
 +      obj_type = oid_object_info(the_repository, object, NULL);
 +      repl_type = oid_object_info(the_repository, repl, NULL);
        if (!force && obj_type != repl_type)
-               die("Objects must be of the same type.\n"
-                   "'%s' points to a replaced object of type '%s'\n"
-                   "while '%s' points to a replacement object of type '%s'.",
-                   object_ref, type_name(obj_type),
-                   replace_ref, type_name(repl_type));
-       check_ref_valid(object, &prev, &ref, force);
+               return error("Objects must be of the same type.\n"
+                            "'%s' points to a replaced object of type '%s'\n"
+                            "while '%s' points to a replacement object of "
+                            "type '%s'.",
+                            object_ref, type_name(obj_type),
+                            replace_ref, type_name(repl_type));
+       if (check_ref_valid(object, &prev, &ref, force)) {
+               strbuf_release(&ref);
+               return -1;
+       }
  
        transaction = ref_transaction_begin(&err);
        if (!transaction ||
@@@ -291,20 -312,32 +315,32 @@@ static int edit_and_replace(const char 
        struct strbuf ref = STRBUF_INIT;
  
        if (get_oid(object_ref, &old_oid) < 0)
-               die("Not a valid object name: '%s'", object_ref);
+               return error("Not a valid object name: '%s'", object_ref);
  
 -      type = oid_object_info(&old_oid, NULL);
 +      type = oid_object_info(the_repository, &old_oid, NULL);
        if (type < 0)
-               die("unable to get object type for %s", oid_to_hex(&old_oid));
+               return error("unable to get object type for %s",
+                            oid_to_hex(&old_oid));
  
-       check_ref_valid(&old_oid, &prev, &ref, force);
+       if (check_ref_valid(&old_oid, &prev, &ref, force)) {
+               strbuf_release(&ref);
+               return -1;
+       }
        strbuf_release(&ref);
  
-       export_object(&old_oid, type, raw, tmpfile);
-       if (launch_editor(tmpfile, NULL, NULL) < 0)
-               die("editing object file failed");
-       import_object(&new_oid, type, raw, tmpfile);
+       tmpfile = git_pathdup("REPLACE_EDITOBJ");
+       if (export_object(&old_oid, type, raw, tmpfile)) {
+               free(tmpfile);
+               return -1;
+       }
+       if (launch_editor(tmpfile, NULL, NULL) < 0) {
+               free(tmpfile);
+               return error("editing object file failed");
+       }
+       if (import_object(&new_oid, type, raw, tmpfile)) {
+               free(tmpfile);
+               return -1;
+       }
        free(tmpfile);
  
        if (!oidcmp(&old_oid, &new_oid))
diff --cc commit.c
Simple merge
diff --cc commit.h
Simple merge
diff --cc log-tree.c
Simple merge