@matheusbsbs / matheus-bagliano / commits / 7b34c2fae0
Fork 0

git-rev-list: make --dense the default (and introduce "--sparse")

This actually does three things: - make "--dense" the default for git-rev-list. Since dense is a no-op if no filenames are given, this doesn't actually change any historical behaviour, but it's logically the right default (if we want to prune on filenames, do it fully. The sparse "merge-only" thing may be useful, but it's not what you'd normally expect) - make "git-rev-parse" show the default revision control before it shows any pathnames. This was a real bug, but nobody would ever have noticed, because the default thing tends to only make sense for git-rev-list, and git-rev-list didn't use to take pathnames. - it changes "git-rev-list" to match the other commands that take a mix of revisions and filenames - it no longer requires the "--" before filenames (although you still need to do it if a filename could be confused with a revision name, eg "gitk" in the git archive) This all just makes for much more pleasant and obvous usage. Just doing a gitk t/ does the obvious thing: it will show the history as it concerns the "t/" subdirectory. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Linus Torvalds committed Oct 25, 2005 at 15:24 UTC 7b34c2fae0d2875b35ad1cc0e416b9c2b9b02b1f
2 files changed +19 -8
rev-list.c
+18 -7
@@ -28,7 +28,7 @@ static const char rev_list_usage[] =
28 " --merge-order [ --show-breaks ]\n"
29 " --topo-order";
30
31 -static int dense = 0;
31 +static int dense = 1;
32 static int unpacked = 0;
33 static int bisect_list = 0;
34 static int tag_objects = 0;
@@ -619,7 +619,7 @@ static struct commit *get_commit_reference(const char *name, unsigned int flags)
619 struct object *object;
620
621 if (get_sha1(name, sha1))
622 - usage(rev_list_usage);
622 + return NULL;
623 object = parse_object(sha1);
624 if (!object)
625 die("bad object %s", name);
@@ -793,12 +793,12 @@ int main(int argc, const char **argv)
793 dense = 1;
794 continue;
795 }
796 + if (!strcmp(arg, "--sparse")) {
797 + dense = 0;
798 + continue;
799 + }
800 if (!strcmp(arg, "--")) {
797 - paths = get_pathspec(prefix, argv + i + 1);
798 - if (paths) {
799 - limited = 1;
800 - diff_tree_setup_paths(paths);
801 - }
801 + i++;
802 break;
803 }
804
@@ -830,9 +830,20 @@ int main(int argc, const char **argv)
830 limited = 1;
831 }
832 commit = get_commit_reference(arg, flags);
833 + if (!commit)
834 + break;
835 handle_one_commit(commit, &list);
836 }
837
838 + if (!list)
839 + usage(rev_list_usage);
840 +
841 + paths = get_pathspec(prefix, argv + i);
842 + if (paths) {
843 + limited = 1;
844 + diff_tree_setup_paths(paths);
845 + }
846 +
847 save_commit_buffer = verbose_header;
848 track_object_refs = 0;
849
rev-parse.c
+1 -1
@@ -153,6 +153,7 @@ static void show_datestring(const char *flag, const char *datestr)
153
154 static void show_file(const char *arg)
155 {
156 + show_default();
157 if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
158 show(arg);
159 }
@@ -174,7 +175,6 @@ int main(int argc, char **argv)
175 if (*arg == '-') {
176 if (!strcmp(arg, "--")) {
177 as_is = 1;
177 - show_default();
178 /* Pass on the "--" if we show anything but files.. */
179 if (filter & (DO_FLAGS | DO_REVS))
180 show_file(arg);