From: Linus Torvalds <torvalds@linux-foundation.org>
To: Junio C Hamano <junkio@cox.net>, Git Mailing List <git@vger.kernel.org>
Subject: Expose subprojects as special files to "git diff" machinery
Date: Sun, 15 Apr 2007 11:14:28 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.64.0704151100550.5473@woody.linux-foundation.org> (raw)
The same way we generate diffs on symlinks as the the diff of text of the
symlink, we can generate subproject diffs (when not recursing into them!)
as the diff of the text that describes the subproject.
Of course, since what descibes a subproject is just the SHA1, that's what
we'll use. Add some pretty-printing to make it a bit more obvious what is
going on, and we're done.
So with this, we can get both raw diffs and "textual" diffs of subproject
changes:
- git diff --raw:
:160000 160000 2de597b5ad348b7db04bd10cdd38cd81cbc93ab5 0000000... M sub-A
- git diff:
diff --git a/sub-A b/sub-A
index 2de597b..e8f11a4 160000
--- a/sub-A
+++ b/sub-A
@@ -1 +1 @@
-Subproject commit 2de597b5ad348b7db04bd10cdd38cd81cbc93ab5
+Subproject commit e8f11a45c5c6b9e2fec6d136d3fb5aff75393d42
NOTE! We'll also want to have the ability to recurse into the subproject
and actually diff it recursively, but that will involve a new command line
option (I'd suggest "--subproject" and "-S", but the latter is in use by
pickaxe), and some very different code.
But regardless of ay future recursive behaviour, we need the non-recursive
version too (and it should be the default, at least in the absense of
config options, so that large superprojects don't default to something
extremely expensive).
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
diff.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/diff.c b/diff.c
index e4efb65..137f5b4 100644
--- a/diff.c
+++ b/diff.c
@@ -1419,6 +1419,21 @@ static int populate_from_stdin(struct diff_filespec *s)
return 0;
}
+static int diff_populate_gitlink(struct diff_filespec *s, int size_only)
+{
+ int len;
+ char *data = xmalloc(100);
+ len = snprintf(data, 100,
+ "Subproject commit %s\n", sha1_to_hex(s->sha1));
+ s->data = data;
+ s->size = len;
+ if (size_only) {
+ s->data = NULL;
+ free(data);
+ }
+ return 0;
+}
+
/*
* While doing rename detection and pickaxe operation, we may need to
* grab the data for the blob (or file) for our own in-core comparison.
@@ -1437,6 +1452,10 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
if (s->data)
return err;
+
+ if (S_ISDIRLNK(s->mode))
+ return diff_populate_gitlink(s, size_only);
+
if (!s->sha1_valid ||
reuse_worktree_file(s->path, s->sha1, 0)) {
struct stat st;
next reply other threads:[~2007-04-15 18:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-15 18:14 Linus Torvalds [this message]
2007-04-15 19:01 ` Expose subprojects as special files to "git diff" machinery Sam Ravnborg
2007-04-15 19:05 ` Linus Torvalds
2007-04-15 19:20 ` Sam Ravnborg
2007-04-15 20:16 ` Andy Parkins
2007-04-15 21:03 ` Linus Torvalds
2007-04-18 8:46 ` git-format-patch for binary files / merges [Re: Expose subprojects as special files to "git diff" machinery] Sam Vilain
2007-04-18 11:49 ` Alex Riesen
2007-04-18 11:52 ` Johannes Schindelin
2007-04-18 15:47 ` Linus Torvalds
2007-04-18 16:08 ` Junio C Hamano
2007-04-19 8:28 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.LNX.4.64.0704151100550.5473@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).