Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide an accessible git askyesno and use is in git update-git-for-windows #234

Merged
merged 3 commits into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion git-extra/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CFLAGS ?= -Wall
CXXFLAGS ?= -Wall

all: $(BUILDDIR)/create-shortcut.exe $(BUILDDIR)/WhoUses.exe \
$(BUILDDIR)/blocked-file-util.exe $(BUILDDIR)/proxy-lookup.exe
$(BUILDDIR)/blocked-file-util.exe $(BUILDDIR)/proxy-lookup.exe \
$(BUILDDIR)/git-askyesno.exe

$(BUILDDIR)/create-shortcut.exe: $(BUILDDIR)/create-shortcut.o
$(CC) $(CFLAGS) -o $@ $^ -luuid -lole32
Expand All @@ -27,6 +28,11 @@ $(BUILDDIR)/blocked-file-util.exe: $(BUILDDIR)/blocked-file-util.o
$(BUILDDIR)/proxy-lookup.exe: $(BUILDDIR)/proxy-lookup.o
$(CC) $(CFLAGS) -o $@ $^ -lshell32 -lwinhttp

$(BUILDDIR)/git-askyesno.o: CFLAGS += -DUNICODE

$(BUILDDIR)/git-askyesno.exe: $(BUILDDIR)/git-askyesno.o
$(CC) -municode $(CFLAGS) -o $@ $^

clean:
$(RM) $(BUILDDIR)/create-shortcut.exe $(BUILDDIR)/create-shortcut.o
$(RM) $(BUILDDIR)/WhoUses.exe $(BUILDDIR)/WhoUses.o \
Expand Down
11 changes: 7 additions & 4 deletions git-extra/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ source=('inputrc'
'git-update'
'blocked-file-util.c'
'zzz_rm_stackdumps.sh'
'proxy-lookup.c')
'proxy-lookup.c'
'git-askyesno.c')
sha256sums=('9efaf8dccc08c7cddc58cb589bab5aac5c0894661175a344ca02b2aa849382bd'
'c26d22aaa1d3dc615d474e0d60c5c0f19598d61d9205e19ec87aac1b28bb07c1'
'640d04d2a2da709419188a986d5e5550ad30df23c7ea9be1a389c37a6b917994'
'17c90698d4dd52dd9f383e72aee54ecea0f62520baf56722de5c83285507c0d9'
'3cd83627f1d20e1108533419fcf33c657cbcf777c3dc39fa7f13748b7d63858a'
'a9ada325a279ce460aeb663a715e4c335d8972f497d48d97ff5524053b1fb43a'
'ad295ceb2c66aaf5fec85705110f701924eb6733b68663aaa52a90b950f03caa'
'b042b772cf66c4d213617770100c6fa84b04947d477b14c8af0cd0f1992357df'
'15b101d6ace1179de71e125e930a004f261cb8a6df4811f80390c3d258ebfc09'
'd212e1bbe75a9f81443126701324c9c44c3ed5750dd9822eba754a1799ed13b3'
'402c51eba82453a76f5110f4754bb1005df507a6e4532574c2b9627ff4e1dc81'
'd9024bab283ebb67b5d39d49ee5d2592e170abf1f92d3db34edcdd7eeed0b6b9'
Expand All @@ -69,11 +70,12 @@ sha256sums=('9efaf8dccc08c7cddc58cb589bab5aac5c0894661175a344ca02b2aa849382bd'
'37e3412480f0fc5b742406d569baa1a6c572f5be16650ae70c65169c5fd4a8e3'
'd05f507c7706642c0fe491d3a5b130666a38ceb8d0263be5d21b631f2d890b5d'
'0df1de94f20047a854d1e201597c3d4ebcc5f7389f272fb031f7424de009e19a'
'591d64c5b906cb315bafd5c157c5a9286d1ba3ce54be121ddecfa4ab3607ed93'
'8789aa76ce7ed6846643e19b41924dd14efb32be195ddb98e8badc11934c6c73'
'15b40ab72dea884f659cfbe441e9a40b2d8d63e490a3c14824a55607368e476d'
'ebd1d20aa94be11c6b9bec7d33614d32016343d282c4716d0561ab41407c99bf'
'97e89689d91747ddb5ee873ae864aebcbb8d0364a52fa198db1e439ee2965b9b'
'2199a518823de64a581854b9173f5f06cab191cfde50f04f3628200127690a4f')
'2199a518823de64a581854b9173f5f06cab191cfde50f04f3628200127690a4f'
'cb94337eb02684b15b75c15d0a75169c6c15c69ec9ee4b35fa99bfe1fb64f9da')

prepare() {
test $startdir/$pkgname.install -nt $startdir/$pkgname.install.in &&
Expand Down Expand Up @@ -116,6 +118,7 @@ package() {
install -m755 $builddir/WhoUses.exe $pkgdir${MINGW_PREFIX}/bin
install -m755 $builddir/blocked-file-util.exe $pkgdir${MINGW_PREFIX}/bin
install -m755 $builddir/proxy-lookup.exe $pkgdir${MINGW_PREFIX}/bin
install -m755 $builddir/git-askyesno.exe $pkgdir${MINGW_PREFIX}/bin
install -m755 git-prompt.sh $pkgdir/etc/profile.d
install -m755 aliases.sh $pkgdir/etc/profile.d
install -m755 env.sh $pkgdir/etc/profile.d
Expand Down
46 changes: 46 additions & 0 deletions git-extra/git-askyesno.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

int wmain(int argc, wchar_t **wargv)
{
int res;
wchar_t *title = L"Question?", *prompt = NULL;

if (argc > 2 && !wcscmp(L"--title", wargv[1])) {
title = wargv[2];
argc -=2;
wargv += 2;
}

if (argc < 2) {
MessageBoxW(NULL, L"Usage: git askyesno <question>", L"Error!", MB_OK);
return 1;
}

if (argc > 2) {
size_t count = wcslen(wargv[1]), i;

for (i = 2; i < argc; i++)
count += 1 + wcslen(wargv[i]);

prompt = malloc((count + 1) * sizeof(*prompt));
if (!prompt) {
MessageBoxW(NULL, L"Out of memory asking a question", L"Error!", MB_OK);
return 1;
}

wcscpy(prompt, wargv[1]);
count = wcslen(wargv[1]);

for (i = 2; i < argc; i++) {
prompt[count++] = L' ';
wcscpy(prompt + count, wargv[i]);
count += wcslen(wargv[i]);
}
}

res = MessageBoxW(NULL, prompt ? prompt : wargv[1], title, MB_YESNO);

free(prompt);
return res == IDYES ? 0 : 1;
}
4 changes: 2 additions & 2 deletions git-extra/git-update-git-for-windows
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ update_git_for_windows () {
# toast not activated, failed, toasts
# unsupported, WinToast init failed or toast
# not launched: fall back to using GUI
git gui--askyesno \
git askyesno \
--title "Git Update Available" \
"Download and install $name$warn?" || {
git config --global \
Expand All @@ -237,7 +237,7 @@ update_git_for_windows () {
esac
elif test -n "$use_gui"
then
git gui--askyesno --title "Git Update Available" \
git askyesno --title "Git Update Available" \
"Download and install $name$warn?" || {
git config --global \
winUpdater.recentlySeenVersion "$latest"
Expand Down