1. Get list of the stashes:
git fsck --unreachable | grep commit | cut -d" " -f3 | xargs git log --merges --no-walk --grep=WIP
2. Find needed commit_hash in the list
3. Run >git stash apply <commit_hash>
1. Get list of the stashes:
git fsck --unreachable | grep commit | cut -d" " -f3 | xargs git log --merges --no-walk --grep=WIP
2. Find needed commit_hash in the list
3. Run >git stash apply <commit_hash>
for i in {1..10}; do command; done
Checkout changed files
git diff --name-only HEAD~ | xargs git checkout HEAD~ --
class CustomType
{
public:
int m_value;
};
class Test
{
public:
const CustomType & get_value() const { return m_value; }
CustomType & get_value() { return m_value; }
private:
CustomType m_value;
};
The piece of code that is below binds both overloads of get_value method:
void add_python_bidings_test( )
{
class_< Test >( "Test" )
.def( "get_value_const", ( const CustomType & (Test::*)() const) &Test::get_value,
boost::python::return_value_policy<boost::python::copy_const_reference>( ))
.def( "get_value", ( CustomType & (Test::*)() ) &Test::get_value,
boost::python::return_value_policy<boost::python::copy_non_const_reference>( ) );
}
I compiled this only on Visual Studio compiler and didn't check inside python, however, I believe it should work.
Please, let me know if you find any issues.
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <cstring>
#include <fcntl.h>
int main(int argc, char ** argv)
{
key_t key = ftok(argv[0], 1);
if (key < 0)
{
perror("ftok"); /*Displays the error message*/
return -1;
}
printf("Key for shared memory: '%s'\n", argv[0]);
int shmid = shmget(key, 4096, IPC_CREAT | O_EXCL | S_IRUSR | S_IWUSR);
if(shmid == -1)
{
fprintf(stderr, "Failed to create memory segment. %s\n",
strerror(errno));
return -1;
}
void * pAddr = shmat(shmid, NULL, 0);
if((long long )pAddr == -1)
{
if(shmctl(shmid, IPC_RMID, NULL) == -1)
{
fprintf(stderr, "Failed to remove shared memory segment. %s\n",
strerror(errno));
return -1;
}
fprintf(stderr, "Failed to attach to shared memory. %s\n",
strerror(errno));
return -1;
}
const char * szcServerMessage = "Hello world!";
strcpy((char *) pAddr, szcServerMessage);
printf("Server put message to shared memory.\n");
printf("Press any key for exit ...\n");
getchar();
if(shmdt(pAddr) == -1)
{
fprintf(stderr, "Failed to detach from shared memory segment. %s\n",
strerror(errno));
return -1;
}
if(shmctl(shmid, IPC_RMID, NULL) == -1)
{
fprintf(stderr, "Failed to remove shared memory segment. %s\n",
strerror(errno));
return -1;
}
return 0;
}
#include <sys/ipc.h>
#include <sys/shm.h>
#include <errno.h>
#include <cstring>
#include <fcntl.h>
int main(int argc, char ** argv)
{
key_t key = ftok("./server", 1);
if (key < 0)
{
perror("ftok"); /*Displays the error message*/
return -1;
}
int shmid = shmget(key, 0, S_IRUSR | S_IWUSR);
if(shmid == -1)
{
fprintf(stderr, "Failed to create memory segment. %s\n",
strerror(errno));
return -1;
}
void * pAddr = shmat(shmid, NULL, 0);
if((long long )pAddr == -1)
{
fprintf(stderr, "Failed to attach to shared memory. %s\n",
strerror(errno));
return -1;
}
char szcBufferMessage[4096];
strcpy(szcBufferMessage, (char *) pAddr);
printf("Client read message from shared memory: %s \n", szcBufferMessage);
printf("Press any key for exit ...\n");
getchar();
if(shmdt(pAddr) == -1)
{
fprintf(stderr, "Failed to detach from shared memory segment. %s\n",
strerror(errno));
return -1;
}
/* In client we shouldn't delete any segment, because it is allocated by server */
return 0;
}
#include <windows.h>
#include <conio.h>
#include <stdio.h>
const unsigned int c_uiSharedMemorySegmentSize = 512;
const char * szcSharedMemorySegmentName = "Global\\HelloMessage";
int main()
{
printf("Shared memory server has been started successfully.\n");
HANDLE hMapFile = CreateFileMapping(
INVALID_HANDLE_VALUE, // use paging file
NULL, // default security
PAGE_READWRITE, // read/write access
0, // maximum object size (high-order DWORD)
c_uiSharedMemorySegmentSize, // maximum object size (low-order DWORD)
szcSharedMemorySegmentName); // name of mapping object
if (hMapFile == NULL)
{
fprintf(stderr, "Could not create file mapping object (%d).\n", GetLastError());
return 1;
}
char * pcBuf = (char *) MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
c_uiSharedMemorySegmentSize);
if (pcBuf == NULL)
{
fprintf(stderr, "Could not map view of file (%d).\n", GetLastError());
CloseHandle(hMapFile);
return 2;
}
// Set memory for child process
const char * szcMessageHelloWorld = "Hello world!";
strcpy(pcBuf, szcMessageHelloWorld);
printf("Message has been written to shared memory segment.\n");
printf("You can start the client to read it.\n");
printf("Press any key to remove shared memory segment and exit ...\n");
getch();
UnmapViewOfFile(pcBuf);
CloseHandle(hMapFile);
return 0;
}
#include <windows.h>
#include <stdio.h>
#include <conio.h>
const unsigned int c_uiSharedMemorySegmentSize = 512;
const char * szcSharedMemorySegmentName = "Global\\HelloMessage";
int main()
{
printf("Shared memory client has been started.\n");
printf("Press any key to read the message from shared memory.\n");
getch();
HANDLE hMapFile = OpenFileMapping(
FILE_MAP_ALL_ACCESS, // read/write access
FALSE, // do not inherit the name
szcSharedMemorySegmentName); // name of mapping object
if (hMapFile == NULL)
{
fprintf(stderr, "Could not open file mapping object (%d).\n", GetLastError());
return 1;
}
const char * pcBuf = static_cast<char *> (MapViewOfFile(hMapFile, // handle to map object
FILE_MAP_ALL_ACCESS, // read/write permission
0,
0,
c_uiSharedMemorySegmentSize));
if (pcBuf == NULL)
{
fprintf(stderr, "Could not map view of file (%d).\n", GetLastError());
CloseHandle(hMapFile);
return 2;
}
printf("Message from shared memory server: '%s'\n", pcBuf);
printf("Press any key to exit ...");
getch();
UnmapViewOfFile(pcBuf);
CloseHandle(hMapFile);
return 0;
}
After you successfully built both examples you can start server at first: