Skip to content

Commit 05682eb

Browse files
committed
Add status/diff
1 parent 1c89296 commit 05682eb

16 files changed

Lines changed: 850 additions & 3 deletions

git2.nobj.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ c_function "version" {
5858
]],
5959
},
6060
subfiles {
61+
"src/checkout_options.nobj.lua",
62+
"src/diff_find_options.nobj.lua",
63+
"src/diff_options.nobj.lua",
64+
"src/diff_delta.nobj.lua",
65+
"src/diff_stat.nobj.lua",
66+
"src/diff_file.nobj.lua",
67+
"src/diff.nobj.lua",
68+
"src/status_options.nobj.lua",
69+
"src/status_list.nobj.lua",
70+
"src/status_entry.nobj.lua",
6171
"src/strarray.nobj.lua",
6272
"src/error.nobj.lua",
6373
"src/repository.nobj.lua",

src/checkout_options.nobj.lua

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
-- Copyright (c) 2010-2012 by Robert G. Jakabosky <bobby@sharedrealm.com>
2+
--
3+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
4+
-- of this software and associated documentation files (the "Software"), to deal
5+
-- in the Software without restriction, including without limitation the rights
6+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
-- copies of the Software, and to permit persons to whom the Software is
8+
-- furnished to do so, subject to the following conditions:
9+
--
10+
-- The above copyright notice and this permission notice shall be included in
11+
-- all copies or substantial portions of the Software.
12+
--
13+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
-- THE SOFTWARE.
20+
21+
object "CheckoutOptions" {
22+
c_source [[
23+
typedef git_checkout_options CheckoutOptions;
24+
]],
25+
constants {
26+
VERSION = 1,
27+
SAFE = 0,
28+
FORCE = 2,
29+
RECREATE_MISSING = 4,
30+
ALLOW_CONFLICTS = 16,
31+
REMOVE_UNTRACKED = 32,
32+
REMOVE_IGNORED = 64,
33+
UPDATE_ONLY = 128,
34+
DONT_UPDATE_INDEX = 256,
35+
NO_REFRESH = 512,
36+
SKIP_UNMERGED = 1024,
37+
USE_OURS = 2048,
38+
USE_THEIRS = 4096,
39+
DISABLE_PATHSPEC_MATCH = 8192,
40+
SKIP_LOCKED_DIRECTORIES = 262144,
41+
DONT_OVERWRITE_IGNORED = 524288,
42+
CONFLICT_STYLE_MERGE = 1048576,
43+
CONFLICT_STYLE_DIFF3 = 2097152,
44+
DONT_REMOVE_EXISTING = 4194304,
45+
DONT_WRITE_INDEX = 8388608,
46+
DRY_RUN = 16777216,
47+
CONFLICT_STYLE_ZDIFF3 = 33554432,
48+
NONE = 1073741824,
49+
UPDATE_SUBMODULES = 65536,
50+
UPDATE_SUBMODULES_IF_CHANGED = 131072,
51+
},
52+
constructor "init" {
53+
c_source [[
54+
${this} = calloc(1, sizeof(CheckoutOptions));
55+
git_checkout_options_init(${this}, GIT_STATUS_OPTIONS_VERSION);
56+
]],
57+
},
58+
destructor {
59+
c_source [[
60+
free(${this});
61+
]]
62+
},
63+
field "unsigned int" "version",
64+
field "unsigned int" "checkout_strategy",
65+
method "set_checkout_strategy" {
66+
var_in { "unsigned int", "checkout_strategy" },
67+
c_source [[
68+
${this}->checkout_strategy = ${checkout_strategy};
69+
]],
70+
},
71+
field "int" "disable_filters",
72+
method "set_disable_filters" {
73+
var_in { "int", "disable_filters" },
74+
c_source [[
75+
${this}->disable_filters = ${disable_filters};
76+
]],
77+
},
78+
field "unsigned int" "dir_mode",
79+
method "set_dir_mode" {
80+
var_in { "unsigned int", "dir_mode" },
81+
c_source [[
82+
${this}->dir_mode = ${dir_mode};
83+
]],
84+
},
85+
field "unsigned int" "file_mode",
86+
method "set_file_mode" {
87+
var_in { "unsigned int", "file_mode" },
88+
c_source [[
89+
${this}->file_mode = ${file_mode};
90+
]],
91+
},
92+
field "int" "file_open_flags",
93+
method "set_file_open_flags" {
94+
var_in { "int", "file_open_flags" },
95+
c_source [[
96+
${this}->file_open_flags = ${file_open_flags};
97+
]],
98+
},
99+
field "unsigned int" "notify_flags",
100+
method "set_notify_flags" {
101+
var_in { "unsigned int", "notify_flags" },
102+
c_source [[
103+
${this}->notify_flags = ${notify_flags};
104+
]],
105+
},
106+
method "paths" {
107+
var_out { "StrArray *", "paths" },
108+
c_source [[
109+
${paths} = &${this}->paths;
110+
]],
111+
},
112+
method "set_paths" {
113+
var_in { "StrArray *", "paths" },
114+
c_source [[
115+
${this}->paths.strings = ${paths}->strings;
116+
${this}->paths.count = ${paths}->count;
117+
]],
118+
},
119+
field "Tree *" "baseline",
120+
method "set_baseline" {
121+
var_in { "Tree *", "baseline" },
122+
c_source [[
123+
${this}->baseline = ${baseline};
124+
]],
125+
},
126+
field "Index *" "baseline_index",
127+
method "set_baseline_index" {
128+
var_in { "Index *", "baseline_index" },
129+
c_source [[
130+
${this}->baseline_index = ${baseline_index};
131+
]],
132+
},
133+
field "const char *" "target_directory",
134+
method "set_target_directory" {
135+
var_in { "const char *", "target_directory" },
136+
c_source [[
137+
${this}->target_directory = ${target_directory};
138+
]],
139+
},
140+
field "const char *" "ancestor_label",
141+
method "set_ancestor_label" {
142+
var_in { "const char *", "ancestor_label" },
143+
c_source [[
144+
${this}->ancestor_label = ${ancestor_label};
145+
]],
146+
},
147+
field "const char *" "our_label",
148+
method "set_our_label" {
149+
var_in { "const char *", "our_label" },
150+
c_source [[
151+
${this}->our_label = ${our_label};
152+
]],
153+
},
154+
field "const char *" "their_label",
155+
method "set_their_label" {
156+
var_in { "const char *", "their_label" },
157+
c_source [[
158+
${this}->their_label = ${their_label};
159+
]],
160+
},
161+
}

src/diff.nobj.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
-- Copyright (c) 2010-2012 by Robert G. Jakabosky <bobby@sharedrealm.com>
2+
--
3+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
4+
-- of this software and associated documentation files (the "Software"), to deal
5+
-- in the Software without restriction, including without limitation the rights
6+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
-- copies of the Software, and to permit persons to whom the Software is
8+
-- furnished to do so, subject to the following conditions:
9+
--
10+
-- The above copyright notice and this permission notice shall be included in
11+
-- all copies or substantial portions of the Software.
12+
--
13+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
-- THE SOFTWARE.
20+
21+
object "Diff" {
22+
c_source [[
23+
typedef git_diff Diff;
24+
]],
25+
constructor "index_to_workdir" {
26+
c_call { "GitError", "err" } "git_diff_index_to_workdir" { "Diff *", "&this>1", "Repository *", "repo", "Index *", "index", "DiffOptions *", "opts" },
27+
},
28+
constructor "tree_to_index" {
29+
c_call { "GitError", "err" } "git_diff_tree_to_index" { "Diff *", "&this>1", "Repository *", "repo", "Tree *", "tree", "Index *", "index", "DiffOptions *", "opts" },
30+
},
31+
constructor "tree_to_workdir_with_index" {
32+
c_call { "GitError", "err" } "git_diff_tree_to_workdir_with_index" { "Diff *", "&this>1", "Repository *", "repo", "Tree *", "tree", "DiffOptions *", "opts" },
33+
},
34+
constructor "tree_to_tree" {
35+
c_call { "GitError", "err" } "git_diff_tree_to_tree" { "Diff *", "&this>1", "Repository *", "repo", "Tree *", "tree", "Tree *", "tree", "DiffOptions *", "opts" },
36+
},
37+
destructor {
38+
c_method_call "void" "git_diff_free" {}
39+
},
40+
method "num" {
41+
c_method_call { "size_t", "count" } "git_diff_num_deltas" {},
42+
},
43+
method "find_similar" {
44+
c_method_call { "GitError", "err" } "git_diff_find_similar" { "DiffFindOptions *", "opts" },
45+
},
46+
}

src/diff_delta.nobj.lua

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
-- Copyright (c) 2010-2012 by Robert G. Jakabosky <bobby@sharedrealm.com>
2+
--
3+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
4+
-- of this software and associated documentation files (the "Software"), to deal
5+
-- in the Software without restriction, including without limitation the rights
6+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
-- copies of the Software, and to permit persons to whom the Software is
8+
-- furnished to do so, subject to the following conditions:
9+
--
10+
-- The above copyright notice and this permission notice shall be included in
11+
-- all copies or substantial portions of the Software.
12+
--
13+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
-- THE SOFTWARE.
20+
21+
object "DiffDelta" {
22+
c_source [[
23+
typedef git_diff_delta DiffDelta;
24+
]],
25+
constants {
26+
UNMODIFIED = 0,
27+
ADDED = 1,
28+
DELETED = 2,
29+
MODIFIED = 3,
30+
RENAMED = 4,
31+
COPIED = 5,
32+
IGNORED = 6,
33+
UNTRACKED = 7,
34+
TYPECHANGE = 8,
35+
UNREADABLE = 9,
36+
CONFLICTED = 10,
37+
},
38+
constructor "get" {
39+
c_call "const DiffDelta *>1" "git_diff_get_delta" { "Diff *", "diff", "size_t", "idx" },
40+
},
41+
field "unsigned int" "status",
42+
field "uint32_t" "flags",
43+
field "uint16_t" "similarity",
44+
field "uint16_t" "nfiles",
45+
method "old_file" {
46+
var_out { "DiffFile *", "old_file" },
47+
c_source [[
48+
${old_file} = &${this}->old_file;
49+
]],
50+
},
51+
method "new_file" {
52+
var_out { "DiffFile *", "new_file" },
53+
c_source [[
54+
${new_file} = &${this}->new_file;
55+
]],
56+
},
57+
}

src/diff_file.nobj.lua

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
-- Copyright (c) 2010-2012 by Robert G. Jakabosky <bobby@sharedrealm.com>
2+
--
3+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
4+
-- of this software and associated documentation files (the "Software"), to deal
5+
-- in the Software without restriction, including without limitation the rights
6+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
-- copies of the Software, and to permit persons to whom the Software is
8+
-- furnished to do so, subject to the following conditions:
9+
--
10+
-- The above copyright notice and this permission notice shall be included in
11+
-- all copies or substantial portions of the Software.
12+
--
13+
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
-- THE SOFTWARE.
20+
21+
object "DiffFile" {
22+
c_source [[
23+
typedef git_diff_file DiffFile;
24+
]],
25+
constants {
26+
BINARY = 1,
27+
NOT_BINARY = 2,
28+
VALID_ID = 4,
29+
EXISTS = 8,
30+
VALID_SIZE = 16,
31+
},
32+
destructor {
33+
c_source [[
34+
if(${this}->path != NULL) {
35+
free((void *)${this}->path);
36+
${this}->path = NULL;
37+
}
38+
free(${this});
39+
]]
40+
},
41+
field "OID" "id",
42+
field "const char *" "path",
43+
field "uint64_t" "size",
44+
field "uint32_t" "flags",
45+
field "uint16_t" "mode",
46+
field "uint16_t" "id_abbrev",
47+
}

0 commit comments

Comments
 (0)