Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
for-each-ref --format='%(flag)'
author
Junio C Hamano
<gitster@pobox.com>
Sat, 13 Feb 2010 20:05:44 +0000
(12:05 -0800)
committer
Junio C Hamano
<gitster@pobox.com>
Sat, 13 Feb 2010 20:25:28 +0000
(12:25 -0800)
This expands to "symref" or "packed" or an empty string, exposing the
internal "flag" the for_each_ref() callback functions are called with.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-for-each-ref.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
5cdd628
)
diff --git
a/builtin-for-each-ref.c
b/builtin-for-each-ref.c
index b9b03e14d3f6a6cedb6cf6363d55e4d564cc3d28..62be1bbfd6659f9dfac73a17acd1e2d5322dac66 100644
(file)
--- a/
builtin-for-each-ref.c
+++ b/
builtin-for-each-ref.c
@@
-71,6
+71,7
@@
static struct {
{ "contents" },
{ "upstream" },
{ "symref" },
{ "contents" },
{ "upstream" },
{ "symref" },
+ { "flag" },
};
/*
};
/*
@@
-558,6
+559,13
@@
static void grab_values(struct atom_value *val, int deref, struct object *obj, v
}
}
}
}
+static inline char *copy_advance(char *dst, const char *src)
+{
+ while (*src)
+ *dst++ = *src++;
+ return dst;
+}
+
/*
* Parse the object referred by ref, and grab needed value.
*/
/*
* Parse the object referred by ref, and grab needed value.
*/
@@
-610,6
+618,20
@@
static void populate_value(struct refinfo *ref)
continue;
refname = branch->merge[0]->dst;
}
continue;
refname = branch->merge[0]->dst;
}
+ else if (!strcmp(name, "flag")) {
+ char buf[256], *cp = buf;
+ if (ref->flag & REF_ISSYMREF)
+ cp = copy_advance(cp, ",symref");
+ if (ref->flag & REF_ISPACKED)
+ cp = copy_advance(cp, ",packed");
+ if (cp == buf)
+ v->s = "";
+ else {
+ *cp = '\0';
+ v->s = xstrdup(buf + 1);
+ }
+ continue;
+ }
else
continue;
else
continue;