Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
replace: make sure --edit results in a different object
author
Christian Couder
<chriscool@tuxfamily.org>
Sat, 17 May 2014 12:16:34 +0000
(14:16 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 19 May 2014 20:39:53 +0000
(13:39 -0700)
It's a bad idea to create a replace ref for an object
that points to the original object itself.
That's why we have to check if the result from editing
the original object is a different object and error out
if it isn't.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/replace.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
b892bb4
)
diff --git
a/builtin/replace.c
b/builtin/replace.c
index 3da1bae0a60942f3aad5362f12a4e1db42589f32..07518040395139e9e159617bd7c2da548237bbbf 100644
(file)
--- a/
builtin/replace.c
+++ b/
builtin/replace.c
@@
-275,6
+275,9
@@
static int edit_and_replace(const char *object_ref, int force)
free(tmpfile);
+ if (!hashcmp(old, new))
+ return error("new object is the same as the old one: '%s'", sha1_to_hex(old));
+
return replace_object_sha1(object_ref, old, "replacement", new, force);
}