summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgitk4
-rw-r--r--rev-list.c47
-rw-r--r--rev-parse.c2
3 files changed, 33 insertions, 20 deletions
diff --git a/gitk b/gitk
index f1ea4e1e43..a9d37d9c73 100755
--- a/gitk
+++ b/gitk
@@ -2806,7 +2806,7 @@ proc gettreediffs {ids} {
set treediff {}
set id [lindex $ids 0]
set p [lindex $ids 1]
- if [catch {set gdtf [open "|git-diff-tree -r $p $id" r]}] return
+ if [catch {set gdtf [open "|git-diff-tree -r $id" r]}] return
fconfigure $gdtf -blocking 0
fileevent $gdtf readable [list gettreediffline $gdtf $ids]
}
@@ -2842,7 +2842,7 @@ proc getblobdiffs {ids} {
set id [lindex $ids 0]
set p [lindex $ids 1]
set env(GIT_DIFF_OPTS) $diffopts
- set cmd [list | git-diff-tree -r -p -C $p $id]
+ set cmd [list | git-diff-tree -r -p -C $id]
if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err"
return
diff --git a/rev-list.c b/rev-list.c
index edf3b37874..2b82b8a96c 100644
--- a/rev-list.c
+++ b/rev-list.c
@@ -28,7 +28,7 @@ static const char rev_list_usage[] =
" --merge-order [ --show-breaks ]\n"
" --topo-order";
-static int dense = 0;
+static int dense = 1;
static int unpacked = 0;
static int bisect_list = 0;
static int tag_objects = 0;
@@ -613,13 +613,10 @@ static void add_pending_object(struct object *obj, const char *name)
add_object(obj, &pending_objects, name);
}
-static struct commit *get_commit_reference(const char *name, unsigned int flags)
+static struct commit *get_commit_reference(const char *name, const unsigned char *sha1, unsigned int flags)
{
- unsigned char sha1[20];
struct object *object;
- if (get_sha1(name, sha1))
- usage(rev_list_usage);
object = parse_object(sha1);
if (!object)
die("bad object %s", name);
@@ -697,7 +694,7 @@ static struct commit_list **global_lst;
static int include_one_commit(const char *path, const unsigned char *sha1)
{
- struct commit *com = get_commit_reference(path, 0);
+ struct commit *com = get_commit_reference(path, sha1, 0);
handle_one_commit(com, global_lst);
return 0;
}
@@ -720,6 +717,7 @@ int main(int argc, const char **argv)
const char *arg = argv[i];
char *dotdot;
struct commit *commit;
+ unsigned char sha1[20];
if (!strncmp(arg, "--max-count=", 12)) {
max_count = atoi(arg + 12);
@@ -793,12 +791,12 @@ int main(int argc, const char **argv)
dense = 1;
continue;
}
+ if (!strcmp(arg, "--sparse")) {
+ dense = 0;
+ continue;
+ }
if (!strcmp(arg, "--")) {
- paths = get_pathspec(prefix, argv + i + 1);
- if (paths) {
- limited = 1;
- diff_tree_setup_paths(paths);
- }
+ i++;
break;
}
@@ -808,15 +806,19 @@ int main(int argc, const char **argv)
flags = 0;
dotdot = strstr(arg, "..");
if (dotdot) {
+ unsigned char from_sha1[20];
char *next = dotdot + 2;
- struct commit *exclude = NULL;
- struct commit *include = NULL;
*dotdot = 0;
if (!*next)
next = "HEAD";
- exclude = get_commit_reference(arg, UNINTERESTING);
- include = get_commit_reference(next, 0);
- if (exclude && include) {
+ if (!get_sha1(arg, from_sha1) && !get_sha1(next, sha1)) {
+ struct commit *exclude;
+ struct commit *include;
+
+ exclude = get_commit_reference(arg, from_sha1, UNINTERESTING);
+ include = get_commit_reference(next, sha1, 0);
+ if (!exclude || !include)
+ die("Invalid revision range %s..%s", arg, next);
limited = 1;
handle_one_commit(exclude, &list);
handle_one_commit(include, &list);
@@ -829,10 +831,21 @@ int main(int argc, const char **argv)
arg++;
limited = 1;
}
- commit = get_commit_reference(arg, flags);
+ if (get_sha1(arg, sha1) < 0)
+ break;
+ commit = get_commit_reference(arg, sha1, flags);
handle_one_commit(commit, &list);
}
+ if (!list)
+ usage(rev_list_usage);
+
+ paths = get_pathspec(prefix, argv + i);
+ if (paths) {
+ limited = 1;
+ diff_tree_setup_paths(paths);
+ }
+
save_commit_buffer = verbose_header;
track_object_refs = 0;
diff --git a/rev-parse.c b/rev-parse.c
index 243f89f3cc..adfc68c9be 100644
--- a/rev-parse.c
+++ b/rev-parse.c
@@ -153,6 +153,7 @@ static void show_datestring(const char *flag, const char *datestr)
static void show_file(const char *arg)
{
+ show_default();
if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV))
show(arg);
}
@@ -174,7 +175,6 @@ int main(int argc, char **argv)
if (*arg == '-') {
if (!strcmp(arg, "--")) {
as_is = 1;
- show_default();
/* Pass on the "--" if we show anything but files.. */
if (filter & (DO_FLAGS | DO_REVS))
show_file(arg);