summaryrefslogtreecommitdiff
path: root/update-cache.c
diff options
context:
space:
mode:
authorBryan Larsen <bryan.larsen@gmail.com>2005-07-08 23:52:12 (GMT)
committerLinus Torvalds <torvalds@g5.osdl.org>2005-07-09 00:07:37 (GMT)
commitdf6e151636992edc5824af53b62b451737b0d24d (patch)
tree24523944fbaabeeb963e7ca411ba122f3196a3af /update-cache.c
parent7672db20c2060f20b01788e4a4289ebc5f818605 (diff)
downloadgit-df6e151636992edc5824af53b62b451737b0d24d.zip
git-df6e151636992edc5824af53b62b451737b0d24d.tar.gz
git-df6e151636992edc5824af53b62b451737b0d24d.tar.bz2
[PATCH] Add --info-only option to git-update-cache.
Add --info-only option to git-update-cache. [JC demangled whitespace from the posted patch himself because he liked it so much. Also adjusted to the index_fd() interface slightly done differently from the original one.] Signed-off-by: Bryan Larsen <bryan.larsen@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'update-cache.c')
-rw-r--r--update-cache.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/update-cache.c b/update-cache.c
index d5225c3..cc4298a 100644
--- a/update-cache.c
+++ b/update-cache.c
@@ -12,7 +12,7 @@
* like "git-update-cache *" and suddenly having all the object
* files be revision controlled.
*/
-static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0;
+static int allow_add = 0, allow_remove = 0, allow_replace = 0, not_new = 0, quiet = 0, info_only = 0;
static int force_remove;
/* Three functions to allow overloaded pointer return; see linux/err.h */
@@ -68,7 +68,7 @@ static int add_file_to_cache(char *path)
fd = open(path, O_RDONLY);
if (fd < 0)
return -1;
- if (index_fd(ce->sha1, fd, &st, 1, NULL) < 0)
+ if (index_fd(ce->sha1, fd, &st, !info_only, NULL) < 0)
return -1;
break;
case S_IFLNK:
@@ -77,7 +77,12 @@ static int add_file_to_cache(char *path)
free(target);
return -1;
}
- if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
+ if (info_only) {
+ unsigned char hdr[50];
+ int hdrlen;
+ write_sha1_file_prepare(target, st.st_size, "blob",
+ ce->sha1, hdr, &hdrlen);
+ } else if (write_sha1_file(target, st.st_size, "blob", ce->sha1))
return -1;
free(target);
break;
@@ -382,6 +387,10 @@ int main(int argc, char **argv)
i += 3;
continue;
}
+ if (!strcmp(path, "--info-only")) {
+ info_only = 1;
+ continue;
+ }
if (!strcmp(path, "--force-remove")) {
force_remove = 1;
continue;