Re: [PATCH RFC] parse_object: pass on the original sha1, not the replaced one

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 04 August 2010 14:42:50 Nguyen Thai Ngoc Duy wrote:
> On Wed, Aug 4, 2010 at 9:58 PM, Christian Couder
> 
> <chriscool@xxxxxxxxxxxxx> wrote:
> >> > I will
> >> > try to have a deeper look at that, but it would help if you could give
> >> > an example of a command that triggers this behavior.
> >> 
> >> The following patch add "sha1" command. These commands give different
> >> sha1:
> >> 
> >> git sha1 `git rev-parse HEAD` `git rev-parse HEAD^` A
> >> git sha1 `git rev-parse HEAD` `git rev-parse HEAD^` B
> > 
> > Yes, but that does not mean that the content of the object returned by
> > lookup_commit(A) is not the content of A.
> > 
> > Or do you have an example where the content of the object returned by
> > lookup_commit(A) is not the content of A?
> 
> Both return the content of B. I modified my patch a bit to also show
> the content, ((struct commit*)obj)->buffer.

I also modified your patch but I don't get any content shown when using 
lookup_commit()

I use:

diff --git a/builtin/sha1.c b/builtin/sha1.c
new file mode 100644
index 0000000..8e081b2
--- /dev/null
+++ b/builtin/sha1.c
@@ -0,0 +1,27 @@
+#include "cache.h"
+#include "commit.h"
+
+int cmd_sha1(int argc, char **argv)
+{
+       unsigned char old[20];
+       unsigned char new[20];
+       struct object *obj;
+
+       get_sha1_hex(argv[1], old);
+       get_sha1_hex(argv[2], new);
+       printf("old  = %s\nnew  = %s\n", argv[1], argv[2]);
+       replace_pair(old, new);
+       if (argv[3][0] == 'A')
+              obj = parse_object(old);
+       else {
+              struct commit *com = lookup_commit(old);
+              if (com->buffer)
+                      printf("commit buffer:\n%s", com->buffer);
+              else
+                      printf("no commit buffer\n");
+              obj = (struct object *)com;
+       }
+
+       printf("sha1 = %s\n", sha1_to_hex(obj->sha1));
+       return 0;
+}

and I get:

$ git sha1 `git rev-parse HEAD` `git rev-parse HEAD^` B
old  = 5b4585a035e2ba61573273dacc6d17d7e8fcbc7d
new  = c9b402bd93105f80f3c5d67ecfccc8ba36810613
no commit buffer
sha1 = 5b4585a035e2ba61573273dacc6d17d7e8fcbc7d

Could you show what code you use?

Thanks,
Christian.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]