aboutsummaryrefslogtreecommitdiffstats
path: root/t/helper/test-oidmap.c
diff options
context:
space:
mode:
Diffstat (limited to 't/helper/test-oidmap.c')
-rw-r--r--t/helper/test-oidmap.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index 0acf99931e..bd30244a54 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,7 +1,11 @@
#include "test-tool.h"
-#include "cache.h"
+#include "hex.h"
+#include "object-name.h"
#include "oidmap.h"
+#include "repository.h"
+#include "setup.h"
#include "strbuf.h"
+#include "string-list.h"
/* key is an oid and value is a name (could be a refname for example) */
struct test_entry {
@@ -21,8 +25,9 @@ struct test_entry {
* iterate -> oidkey1 namevalue1\noidkey2 namevalue2\n...
*
*/
-int cmd__oidmap(int argc, const char **argv)
+int cmd__oidmap(int argc UNUSED, const char **argv UNUSED)
{
+ struct string_list parts = STRING_LIST_INIT_NODUP;
struct strbuf line = STRBUF_INIT;
struct oidmap map = OIDMAP_INIT;
@@ -33,23 +38,28 @@ int cmd__oidmap(int argc, const char **argv)
/* process commands from stdin */
while (strbuf_getline(&line, stdin) != EOF) {
- char *cmd, *p1 = NULL, *p2 = NULL;
+ char *cmd, *p1, *p2;
struct test_entry *entry;
struct object_id oid;
/* break line into command and up to two parameters */
- cmd = strtok(line.buf, DELIM);
+ string_list_setlen(&parts, 0);
+ string_list_split_in_place(&parts, line.buf, DELIM, 2);
+ string_list_remove_empty_items(&parts, 0);
+
/* ignore empty lines */
- if (!cmd || *cmd == '#')
+ if (!parts.nr)
+ continue;
+ if (!*parts.items[0].string || *parts.items[0].string == '#')
continue;
- p1 = strtok(NULL, DELIM);
- if (p1)
- p2 = strtok(NULL, DELIM);
+ cmd = parts.items[0].string;
+ p1 = parts.nr >= 1 ? parts.items[1].string : NULL;
+ p2 = parts.nr >= 2 ? parts.items[2].string : NULL;
if (!strcmp("put", cmd) && p1 && p2) {
- if (get_oid(p1, &oid)) {
+ if (repo_get_oid(the_repository, p1, &oid)) {
printf("Unknown oid: %s\n", p1);
continue;
}
@@ -67,7 +77,7 @@ int cmd__oidmap(int argc, const char **argv)
} else if (!strcmp("get", cmd) && p1) {
- if (get_oid(p1, &oid)) {
+ if (repo_get_oid(the_repository, p1, &oid)) {
printf("Unknown oid: %s\n", p1);
continue;
}
@@ -80,7 +90,7 @@ int cmd__oidmap(int argc, const char **argv)
} else if (!strcmp("remove", cmd) && p1) {
- if (get_oid(p1, &oid)) {
+ if (repo_get_oid(the_repository, p1, &oid)) {
printf("Unknown oid: %s\n", p1);
continue;
}
@@ -106,6 +116,7 @@ int cmd__oidmap(int argc, const char **argv)
}
}
+ string_list_clear(&parts, 0);
strbuf_release(&line);
oidmap_free(&map, 1);
return 0;
>1-6/+12 2008-04-04git-gui: Update french translationChristian Couder1-45/+33 2008-04-03git-gui: Switch keybindings for [ and ] to bracketleft and bracketrightShawn O. Pearce1-4/+4 2008-04-02GIT 1.5.5-rc3v1.5.5-rc3Junio C Hamano2-5/+5 2008-04-02Describe the bug in handling filenames with funny characters in 'git add -i'Teemu Likonen1-0/+6 2008-04-02t7004-tag: Skip more tests if gpg is not available.Johannes Sixt1-7/+8 2008-04-02verify-tag: Clean up the temporary file if gpg cannot be started.Johannes Sixt1-1/+3 2008-04-01help: Add a missing OPT_END().Christian Couder1-0/+1 2008-04-01Accept git aliases outside a git repositoryJunio C Hamano1-1/+2 2008-04-02git-gui 0.10gitgui-0.10.0Shawn O. Pearce1-1/+1 2008-04-02git-gui: Add shortcut keys for Show More/Less ContextJonathan del Strother1-8/+32 2008-03-31mktag.c: tweak validation of tagger field and adjust test scriptBrandon Casey2-31/+86 2008-03-31filter-branch: Fix renaming a directory in the tree-filterveillette@yahoo.ca2-2/+2 2008-03-31filter-branch: Test renaming directories in a tree-filterJohannes Sixt1-2/+18 2008-03-30mktag.c: improve verification of tagger field and testsBrandon Casey2-14/+176 2008-03-30diff-files: careful when inspecting work tree itemsJunio C Hamano2-9/+14 2008-03-30diff-index: careful when inspecting work tree itemsJunio C Hamano2-15/+56