Skip to content

Commit 352cf6c

Browse files
committed
Merge branch 'js/deprecate-grafts'
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
2 parents 5002702 + a3694d9 commit 352cf6c

File tree

14 files changed

+274
-118
lines changed

14 files changed

+274
-118
lines changed

Documentation/git-filter-branch.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ git filter-branch --parent-filter \
288288
or even simpler:
289289

290290
-----------------------------------------------
291-
echo "$commit-id $graft-id" >> .git/info/grafts
291+
git replace --graft $commit-id $graft-id
292292
git filter-branch $graft-id..HEAD
293293
-----------------------------------------------
294294

Documentation/git-replace.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SYNOPSIS
1111
'git replace' [-f] <object> <replacement>
1212
'git replace' [-f] --edit <object>
1313
'git replace' [-f] --graft <commit> [<parent>...]
14+
'git replace' [-f] --convert-graft-file
1415
'git replace' -d <object>...
1516
'git replace' [--format=<format>] [-l [<pattern>]]
1617

@@ -87,9 +88,13 @@ OPTIONS
8788
content as <commit> except that its parents will be
8889
[<parent>...] instead of <commit>'s parents. A replacement ref
8990
is then created to replace <commit> with the newly created
90-
commit. See contrib/convert-grafts-to-replace-refs.sh for an
91-
example script based on this option that can convert grafts to
92-
replace refs.
91+
commit. Use `--convert-graft-file` to convert a
92+
`$GIT_DIR/info/grafts` file and use replace refs instead.
93+
94+
--convert-graft-file::
95+
Creates graft commits for all entries in `$GIT_DIR/info/grafts`
96+
and deletes that file upon success. The purpose is to help users
97+
with transitioning off of the now-deprecated graft file.
9398

9499
-l <pattern>::
95100
--list <pattern>::

Documentation/technical/shallow.txt

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ repo, and therefore grafts are introduced pretending that
88
these commits have no parents.
99
*********************************************************
1010

11-
The basic idea is to write the SHA-1s of shallow commits into
12-
$GIT_DIR/shallow, and handle its contents like the contents
13-
of $GIT_DIR/info/grafts (with the difference that shallow
14-
cannot contain parent information).
15-
16-
This information is stored in a new file instead of grafts, or
17-
even the config, since the user should not touch that file
18-
at all (even throughout development of the shallow clone, it
19-
was never manually edited!).
11+
$GIT_DIR/shallow lists commit object names and tells Git to
12+
pretend as if they are root commits (e.g. "git log" traversal
13+
stops after showing them; "git fsck" does not complain saying
14+
the commits listed on their "parent" lines do not exist).
2015

2116
Each line contains exactly one SHA-1. When read, a commit_graft
2217
will be constructed, which has nr_parent < 0 to make it easier
2318
to discern from user provided grafts.
2419

20+
Note that the shallow feature could not be changed easily to
21+
use replace refs: a commit containing a `mergetag` is not allowed
22+
to be replaced, not even by a root commit. Such a commit can be
23+
made shallow, though. Also, having a `shallow` file explicitly
24+
listing all the commits made shallow makes it a *lot* easier to
25+
do shallow-specific things such as to deepen the history.
26+
2527
Since fsck-objects relies on the library to read the objects,
2628
it honours shallow commits automatically.
2729

advice.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ int advice_rm_hints = 1;
2020
int advice_add_embedded_repo = 1;
2121
int advice_ignored_hook = 1;
2222
int advice_waiting_for_editor = 1;
23+
int advice_graft_file_deprecated = 1;
2324

2425
static int advice_use_color = -1;
2526
static char advice_colors[][COLOR_MAXLEN] = {
@@ -70,6 +71,7 @@ static struct {
7071
{ "addembeddedrepo", &advice_add_embedded_repo },
7172
{ "ignoredhook", &advice_ignored_hook },
7273
{ "waitingforeditor", &advice_waiting_for_editor },
74+
{ "graftfiledeprecated", &advice_graft_file_deprecated },
7375

7476
/* make this an alias for backward compatibility */
7577
{ "pushnonfastforward", &advice_push_update_rejected }

advice.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern int advice_rm_hints;
2121
extern int advice_add_embedded_repo;
2222
extern int advice_ignored_hook;
2323
extern int advice_waiting_for_editor;
24+
extern int advice_graft_file_deprecated;
2425

2526
int git_default_advice_config(const char *var, const char *value);
2627
__attribute__((format (printf, 1, 2)))

argv-array.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ void argv_array_pop(struct argv_array *array)
6464
array->argc--;
6565
}
6666

67+
void argv_array_split(struct argv_array *array, const char *to_split)
68+
{
69+
while (isspace(*to_split))
70+
to_split++;
71+
for (;;) {
72+
const char *p = to_split;
73+
74+
if (!*p)
75+
break;
76+
77+
while (*p && !isspace(*p))
78+
p++;
79+
argv_array_push_nodup(array, xstrndup(to_split, p - to_split));
80+
81+
while (isspace(*p))
82+
p++;
83+
to_split = p;
84+
}
85+
}
86+
6787
void argv_array_clear(struct argv_array *array)
6888
{
6989
if (array->argv != empty_argv) {

argv-array.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ LAST_ARG_MUST_BE_NULL
1919
void argv_array_pushl(struct argv_array *, ...);
2020
void argv_array_pushv(struct argv_array *, const char **);
2121
void argv_array_pop(struct argv_array *);
22+
/* Splits by whitespace; does not handle quoted arguments! */
23+
void argv_array_split(struct argv_array *, const char *);
2224
void argv_array_clear(struct argv_array *);
2325
const char **argv_array_detach(struct argv_array *);
2426

0 commit comments

Comments
 (0)