diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2019-08-05 08:02:40 (GMT) |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-08-05 21:33:39 (GMT) |
commit | 7c5c9b9c57d58273d17dfc3fec3ebdb25077a9de (patch) | |
tree | 4ec3d2ce70ce0f3ee4bbd4d68de7a7fe82ea0b2e /commit-graph.h | |
parent | 39d88318569188c0544c3c0f8207f2e1b1829e60 (diff) | |
download | git-7c5c9b9c57d58273d17dfc3fec3ebdb25077a9de.zip git-7c5c9b9c57d58273d17dfc3fec3ebdb25077a9de.tar.gz git-7c5c9b9c57d58273d17dfc3fec3ebdb25077a9de.tar.bz2 |
commit-graph: error out on invalid commit oids in 'write --stdin-commits'
While 'git commit-graph write --stdin-commits' expects commit object
ids as input, it accepts and silently skips over any invalid commit
object ids, and still exits with success:
# nonsense
$ echo not-a-commit-oid | git commit-graph write --stdin-commits
$ echo $?
0
# sometimes I forgot that refs are not good...
$ echo HEAD | git commit-graph write --stdin-commits
$ echo $?
0
# valid tree OID, but not a commit OID
$ git rev-parse HEAD^{tree} | git commit-graph write --stdin-commits
$ echo $?
0
$ ls -l .git/objects/info/commit-graph
ls: cannot access '.git/objects/info/commit-graph': No such file or directory
Check that all input records are indeed valid commit object ids and
return with error otherwise, the same way '--stdin-packs' handles
invalid input; see e103f7276f (commit-graph: return with errors during
write, 2019-06-12).
Note that it should only return with error when encountering an
invalid commit object id coming from standard input. However,
'--reachable' uses the same code path to process object ids pointed to
by all refs, and that includes tag object ids as well, which should
still be skipped over. Therefore add a new flag to 'enum
commit_graph_write_flags' and a corresponding field to 'struct
write_commit_graph_context', so we can differentiate between those two
cases.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Acked-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit-graph.h')
-rw-r--r-- | commit-graph.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/commit-graph.h b/commit-graph.h index ae4db87..486e64e 100644 --- a/commit-graph.h +++ b/commit-graph.h @@ -74,7 +74,9 @@ int generation_numbers_enabled(struct repository *r); enum commit_graph_write_flags { COMMIT_GRAPH_WRITE_APPEND = (1 << 0), COMMIT_GRAPH_WRITE_PROGRESS = (1 << 1), - COMMIT_GRAPH_WRITE_SPLIT = (1 << 2) + COMMIT_GRAPH_WRITE_SPLIT = (1 << 2), + /* Make sure that each OID in the input is a valid commit OID. */ + COMMIT_GRAPH_WRITE_CHECK_OIDS = (1 << 3) }; struct split_commit_graph_opts { |