-
Notifications
You must be signed in to change notification settings - Fork 2
/
LGit.h
executable file
·271 lines (227 loc) · 12.5 KB
/
LGit.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the LGIT_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// LGIT_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef LGIT_EXPORTS
#define LGIT_API extern "C" __declspec(dllexport)
#else
#define LGIT_API extern "C" __declspec(dllimport)
#endif
/* Useful macros */
#define MF_IF(x) ((x) ? MF_ENABLED : MF_GRAYED)
#define MF_IF_CMD(x) (MF_BYCOMMAND | MF_IF(x))
#define CheckMenuItemIf(menu, command, cond) \
CheckMenuItem(menu, command, MF_BYCOMMAND | ((cond) ? MF_CHECKED : MF_UNCHECKED))
/* Useful macros for simple conversions. Note -1 will copy the NUL too. */
#define LGitWideToUtf8(wide, utf8, utf8size) WideCharToMultiByte(CP_UTF8, 0, wide, -1, utf8, utf8size, NULL, NULL)
/* this is in wide codepoints */
#define LGitUtf8ToWide(utf8, wide, widesize) MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wide, widesize)
/* XXX: Use a case-insensitive comparator */
typedef std::set<std::string> CheckoutQueue;
/* Defining here so they can be defined in ctx; used in cmdopts.cpp */
typedef struct _LGitCommitOpts {
BOOL push;
} LGitCommitOpts;
typedef struct _LGitGetOpts {
BOOL pull;
} LGitGetOpts;
typedef struct _LGitContext {
/* housekeeping */
BOOL active;
HINSTANCE dllInst;
/* With shared SCC subproject, so we don't free IDE provided dir string */
BOOL addSccSuccess;
/* git state */
git_repository *repo;
/* used for faking checkout status */
CheckoutQueue *checkouts;
/* callbacks and such provided by IDE */
OPTNAMECHANGEPFN renameCb;
LPVOID renameData;
LPTEXTOUTPROC textoutCb;
/* Progress dialog, used and destroyed on demand */
IProgressDialog *progress;
BOOL progressCancelled;
/* big in case of Windows 10. keep a wide copy in case */
char path[1024], workdir_path[1024];
/* path isn't really used right now */
wchar_t workdir_path_utf16[1024];
char appName[SCC_NAME_SIZE];
/* SCC provided username, used for some remote contexts */
char username[SCC_USER_SIZE];
/* Command options */
LGitCommitOpts commitOpts;
LGitGetOpts getOpts;
/* Fonts */
HFONT listviewFont, fixedFont;
/* Image lists (make sure that dialogs are shared IL) and helper vars */
HIMAGELIST refTypeIl;
int bitmapHeight; /* y-adjustment when text is taller than bitmap */
} LGitContext;
/* LGit.cpp */
const char* LGitCommandName(enum SCCCOMMAND command);
/* caps.cpp */
LONG LGitGetCaps(void);
/* project.cpp */
LGIT_API SCCRTN LGitOpenProject(LPVOID context, HWND hWnd, LPSTR lpUser, LPSTR lpProjName, LPCSTR lpLocalProjPath, LPSTR lpAuxProjPath, LPCSTR lpComment, LPTEXTOUTPROC lpTextOutProc, LONG dwFlags);
LGIT_API SCCRTN LGitGetProjPath(LPVOID context, HWND hWnd, LPSTR lpUser, LPSTR lpProjName, LPSTR lpLocalPath, LPSTR lpAuxProjPath, BOOL bAllowChangePath, LPBOOL pbNew);
/* logging.cpp */
void LGitLog(const char *format_str, ...);
void LGitLibraryError(HWND hWnd, LPCSTR title);
/* path.cpp */
void LGitFreePathList(char **paths, int path_count);
LGIT_API void LGitTranslateStringChars(char *buf, int char1, int char2);
LGIT_API void LGitTranslateStringCharsW(wchar_t *buf, int char1, int char2);
const char *LGitStripBasePath(LGitContext *ctx, const char *abs);
const wchar_t *LGitStripBasePathW(LGitContext *ctx, const wchar_t *abs);
LGIT_API BOOL LGitGetProjectNameFromPath(char *project, const char *path, size_t bufsz);
void LGitOpenFiles(LGitContext *ctx, git_strarray *paths);
BOOL LGitCreateShortcut(LGitContext *ctx, HWND hwnd);
SCCRTN LGitOpenNewInstance(LGitContext *ctx, const char *file, HWND hwnd);
/* unicode.cpp */
char *LGitWideToUtf8Alloc(const wchar_t *buf);
wchar_t *LGitUtf8ToWideAlloc(const char *buf);
char *LGitAnsiToUtf8Alloc(const char *buf);
int LGitAnsiToUtf8(const char *buf, char *utf8_buf, size_t utf8_bufsz);
int LGitUtf8ToAnsi(const char *buf, char *ansi_buf, size_t ansi_bufsz);
/* format.cpp */
BOOL LGitTimeToString(const git_time *time, char *buf, size_t bufsz);
int LGitFormatSignature(const git_signature *sig, char *buf, size_t bufsz);
BOOL LGitTimeToStringW(const git_time *time, wchar_t *buf, size_t bufsz);
int LGitFormatSignatureW(const git_signature *sig, wchar_t *buf, size_t bufsz);
int LGitFormatSignatureWithTimeW(const git_signature *sig, wchar_t *buf, size_t bufsz);
UINT LGitGitToWindowsCodepage(const char *encoding);
const char *LGitRepoStateString(int state);
const char *LGitBranchType(git_branch_t type);
void LGitLfToCrLf(char *crlf, const char *lf, size_t crlf_len);
void LGitSetWindowTextFromCommitMessage(HWND ctrl, UINT codepage, const char *message);
/* checkout.cpp */
SCCRTN LGitCheckoutStaged(LGitContext *ctx, HWND hwnd, git_strarray *paths);
SCCRTN LGitCheckoutHead(LGitContext *ctx, HWND hwnd, git_strarray *paths);
SCCRTN LGitCheckoutRef(LGitContext *ctx, HWND hwnd, git_reference *branch);
SCCRTN LGitCheckoutRefByName(LGitContext *ctx, HWND hwnd, const char *name);
SCCRTN LGitCheckoutTree(LGitContext *ctx, HWND hwnd, const git_oid *commit_oid);
void LGitPushCheckout(LGitContext *ctx, const char *fileName);
BOOL LGitPopCheckout(LGitContext *ctx, const char *fileName);
BOOL LGitIsCheckout(LGitContext *ctx, const char *fileName);
/* coutcflt.cpp */
SCCRTN LGitInitCheckoutNotifyCallbacks(LGitContext *ctx, HWND hwnd, git_checkout_options *co_opts);
SCCRTN LGitFinishCheckoutNotify(LGitContext *ctx, HWND hwnd, git_checkout_options *co_opts);
/* commit.cpp */
SCCRTN LGitCommitIndex(HWND hWnd, LGitContext *ctx, git_index *index, LPCSTR lpComment, git_signature *author, git_signature *committer);
SCCRTN LGitCommitIndexAmendHead(HWND hWnd, LGitContext *ctx, git_index *index, LPCSTR lpComment, git_signature *author, git_signature *committer);
/* commitmk.cpp */
SCCRTN LGitCreateCommitDialog(LGitContext *ctx, HWND hwnd, BOOL amend_last, const char *proposed_message, git_index *proposed_index);
/* status.cpp */
SCCRTN LGitFileProperties(LGitContext *ctx, HWND hWnd, LPCSTR relative_path);
/* revert.cpp */
SCCRTN LGitRevertCommit(LGitContext *ctx, HWND hwnd, const git_oid *commit_oid);
SCCRTN LGitResetToCommit(LGitContext *ctx, HWND hwnd, const git_oid *commit_oid, BOOL hard);
/* cherry.cpp */
SCCRTN LGitCherryPickCommit(LGitContext *ctx, HWND hwnd, const git_oid *commit_oid);
/* history.cpp */
SCCRTN LGitHistoryForRefByName(LPVOID context, HWND hWnd, const char *ref);
SCCRTN LGitHistory(LPVOID context, HWND hWnd, git_strarray *paths);
/* pushpull.cpp */
typedef enum _LGitPullStrategy {
LGPS_FETCH = 0,
LGPS_MERGE_TO_HEAD = 1,
} LGitPullStrategy;
SCCRTN LGitPush(LGitContext *ctx, HWND hwnd, git_remote *remote, git_reference *refname);
SCCRTN LGitPushDialog(LGitContext *ctx, HWND hwnd);
SCCRTN LGitPull(LGitContext *ctx, HWND hwnd, git_remote *remote, LGitPullStrategy strategy);
SCCRTN LGitPullDialog(LGitContext *ctx, HWND hwnd);
/* merge.cpp */
SCCRTN LGitMergeFastForward(LGitContext *ctx, HWND hwnd, const git_oid *target_oid, BOOL is_unborn);
SCCRTN LGitMergeNormal(LGitContext *ctx, HWND hwnd, const git_annotated_commit *ac, git_merge_preference_t preference);
SCCRTN LGitMerge(LGitContext *ctx, HWND hwnd, const git_annotated_commit *ann);
SCCRTN LGitMergeRefByName(LGitContext *ctx, HWND hwnd, const char *name);
SCCRTN LGitShowMergeConflicts(LGitContext *ctx, HWND hwnd, git_index *index);
/* clone.cpp */
LGIT_API SCCRTN LGitClone(LGitContext *ctx, HWND hWnd, LPSTR lpProjName, LPSTR lpLocalPath, LPBOOL pbNew);
/* stage.cpp */
SCCRTN LGitStageAddFiles(LGitContext *ctx, HWND hwnd, git_strarray *paths, BOOL update);
SCCRTN LGitStageRemoveFiles(LGitContext *ctx, HWND hwnd, git_strarray *paths);
SCCRTN LGitStageUnstageFiles(LGitContext *ctx, HWND hwnd, git_strarray *paths);
SCCRTN LGitStageAddDialog(LGitContext *ctx, HWND hwnd);
SCCRTN LGitStageDragTarget(LGitContext *ctx, HWND hwnd, HDROP drop);
/* tag.cpp */
SCCRTN LGitAddTagDialog(LGitContext *ctx, HWND hwnd);
/* diffwin.cpp */
typedef struct _LGitDiffDialogParams {
LGitContext *ctx;
git_diff *diff;
git_commit *commit;
/* Only likely relevant for single-file SccDiff */
const char *path;
/* Internal done by LGitDiffWindow */
HMENU menu;
} LGitDiffDialogParams;
int LGitDiffWindow(HWND parent, LGitDiffDialogParams *params);
/* diff.cpp */
SCCRTN LGitCommitToCommitDiff(LGitContext *ctx, HWND hwnd, git_commit *commit_b, git_commit *commit_a, git_diff_options *diffopts);
SCCRTN LGitCommitToParentDiff(LGitContext *ctx, HWND hwnd, git_commit *commit, git_diff_options *diffopts);
SCCRTN LGitDiffStageToWorkdir(LGitContext *ctx, HWND hwnd, git_strarray *paths);
SCCRTN LGitDiffTreeToWorkdir(LGitContext *ctx, HWND hwnd, git_strarray *paths, git_tree *tree);
/* apply.cpp */
SCCRTN LGitApplyPatch(LGitContext *ctx, HWND hwnd, git_diff *diff, git_apply_location_t loc, BOOL check_only);
SCCRTN LGitFileToDiff(LGitContext *ctx, HWND hwnd, const wchar_t *file, git_diff **out);
SCCRTN LGitApplyPatchDialog(LGitContext *ctx, HWND hwnd);
/* sigwin.cpp */
SCCRTN LGitSignatureDialog(LGitContext *ctx, HWND parent, char *name, size_t name_sz, char *mail, size_t mail_sz, BOOL enable_set_default);
SCCRTN LGitGetDefaultSignature(HWND hWnd, LGitContext *ctx, git_signature **signature);
/* commitvw.cpp */
void LGitViewCommitInfo(LGitContext *ctx, HWND hWnd, git_commit *commit, git_tag *tag);
/* gitconf.cpp */
SCCRTN LGitManageConfig(LGitContext *ctx, HWND hwnd, git_config *config, const char *title);
/* progress.cpp */
BOOL LGitProgressInit(LGitContext *ctx, const char *title, UINT anim);
BOOL LGitProgressStart(LGitContext *ctx, HWND parent, BOOL quantifiable);
BOOL LGitProgressDeinit(LGitContext *ctx);
BOOL LGitProgressSet(LGitContext *ctx, ULONGLONG x, ULONGLONG outof);
BOOL LGitProgressText(LGitContext *ctx, const char *text, int line);
BOOL LGitProgressCancelled(LGitContext *ctx);
void LGitInitCheckoutProgressCallback(LGitContext *ctx, git_checkout_options *co_opts);
void LGitInitDiffProgressCallback(LGitContext *ctx, git_diff_options *diff_opts);
/* branch.cpp */
SCCRTN LGitShowBranchManager(LGitContext *ctx, HWND hwnd);
/* remote.cpp */
SCCRTN LGitShowRemoteManager(LGitContext *ctx, HWND hwnd);
/* remotecb.cpp */
void LGitInitRemoteCallbacks(LGitContext *ctx, HWND hWnd, git_remote_callbacks *cb);
/* revparse.cpp */
SCCRTN LGitRevparseDialog(LGitContext *ctx, HWND hwnd, const char *title, const char *suggested_spec, git_object **obj, git_reference **ref);
SCCRTN LGitRevparseDialogString(LGitContext *ctx, HWND hwnd, const char *title, char *spec, size_t bufsz);
/* cert.cpp */
BOOL LGitCertificatePrompt(LGitContext *ctx, HWND parent, git_cert *cert, const char *host);
/* string.cpp */
char *strcasestr(const char *s, const char *find);
wchar_t *wcscasestr(const wchar_t *s, const wchar_t *find);
size_t strlcat(char *dst, const char *src, size_t siz);
size_t strlcpy(char *dst, const char *src, size_t siz);
size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t dsize);
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t dsize);
/* winutil.cpp */
void LGitPopulateRemoteComboBox(HWND parent, HWND cb, LGitContext *ctx);
void LGitPopulateReferenceComboBox(HWND parent, HWND cb, LGitContext *ctx);
BOOL LGitBrowseForFolder(HWND hwnd, const wchar_t *title, wchar_t *buf, size_t bufsz);
void LGitSetWindowIcon(HWND hwnd, HINSTANCE inst, LPCSTR name);
void LGitUninitializeFonts(LGitContext *ctx);
void LGitInitializeFonts(LGitContext *ctx);
void LGitSetMonospaceFont(LGitContext *ctx, HWND ctrl);
LONG LGitMeasureWidth(HWND measure_with, const char *text);
LONG LGitMeasureWidthW(HWND measure_with, const wchar_t *text);
BOOL CALLBACK LGitImmutablePropSheetProc(HWND hwnd, unsigned int iMsg, LPARAM lParam);
BOOL LGitContextMenuFromSubmenu(HWND hwnd, HMENU menu, int position, int x, int y);
void LGitControlFillsParentDialog(HWND hwnd, UINT dlg_item);
void LGitControlFillsParentDialogCarveout(HWND hwnd, UINT dlg_item, RECT *bounds);
HIMAGELIST LGitGetSystemImageList();
BOOL LGitMeasureIconComboBoxItem(HWND hwnd, UINT uCtrlId, MEASUREITEMSTRUCT *mis);
BOOL LGitDrawIconComboBox(LGitContext *ctx, HIMAGELIST il, HWND hwnd, UINT uCtrlId, DRAWITEMSTRUCT *dis);
int LGitGetIconForRef(LGitContext *ctx, git_reference *ref);
/* about.cpp */
void LGitAbout(HWND hwnd, LGitContext *ctx);
/* runscc.cpp */
LGIT_API SCCRTN LGitStandaloneExplorer(LGitContext *ctx, LONG nFiles, LPCSTR* lpFileNames);